Class: Channel
Hierarchy
-
Base↳Channel
Table of contents
Constructors
Properties
Methods
- bulkDeleteMessages
- createInvite
- createWebhook
- createdAt
- createdTimestamp
- crosspostMessage
- delete
- edit
- editMessage
- fetchMessage
- fetchMessages
- getInvites
- getWebhooks
- isDMBased
- isTextBased
- isThread
- isVoiceBased
- pinMessage
- send
- toString
- unpinMessage
Constructors
constructor
• new Channel(client, data): Channel
Constructs a new instance of the class.
Parameters
| Name | Type | Description |
|---|---|---|
client | YorClient | The client object. |
data | undefined | { flags?: ChannelFlags ; id: string ; name?: null | string ; type: GuildText | DM | GuildVoice | GroupDM | GuildCategory | GuildAnnouncement | AnnouncementThread | PublicThread | PrivateThread | GuildStageVoice | GuildForum | GuildMedia } | The channel data. |
Returns
Channel
Throws
If channel data is not provided.
Overrides
Base.constructorDefined in
src/structures/Channel.ts:45Properties
API
•Private API: ChannelsAPI
Defined in
src/structures/Channel.ts:36client
• client:YorClient
Inherited from
Base.clientDefined in
src/structures/Base.ts:4flags
•Optional flags: ChannelFlags
Defined in
src/structures/Channel.ts:32id
• id:string
Defined in
src/structures/Channel.ts:29name
• name:undefined | string
Defined in
src/structures/Channel.ts:30raw
• raw:Partial<APIChannel>
Defined in
src/structures/Channel.ts:34type
• type:number
Defined in
src/structures/Channel.ts:31Methods
bulkDeleteMessages
▸ bulkDeleteMessages(messages): Promise<void>
Bulk deletes messages
Parameters
| Name | Type | Description |
|---|---|---|
messages | string[] | The data used to bulk delete messages |
Returns
Promise<void>
Promise that resolves when the messages are deleted
Defined in
src/structures/Channel.ts:169createInvite
▸ createInvite(data): Promise<APIInvite>
Creates an invite using the given data and returns the created invite.
Parameters
| Name | Type | Description |
|---|---|---|
data | RESTPostAPIChannelInviteJSONBody | The data used to create the invite. |
Returns
Promise<APIInvite>
The created invite.
Defined in
src/structures/Channel.ts:129createWebhook
▸ createWebhook(data): Promise<Webhook>
Creates a webhook in the current channel or parent channel (if a thread) with the given data
Parameters
| Name | Type | Description |
|---|---|---|
data | RESTPostAPIChannelWebhookJSONBody & { reason: string } | The data for creating the webhook. |
Returns
Promise<Webhook>
A promise that resolves with the created webhook.
Defined in
src/structures/Channel.ts:274createdAt
▸ createdAt():Date
Returns the creation date of the object.
Returns
Date
The creation date of the object.
Defined in
src/structures/Channel.ts:212createdTimestamp
▸ createdTimestamp():number
Returns the created timestamp as a Date object.
Returns
number
The created timestamp.
Defined in
src/structures/Channel.ts:198crosspostMessage
▸ crosspostMessage(messageId): Promise<APIMessage>
Crossposts a message.
Parameters
| Name | Type | Description |
|---|---|---|
messageId | string | The ID of the message to crosspost. |
Returns
Promise<APIMessage>
A promise that resolves to the crossposted message.
Defined in
src/structures/Channel.ts:119delete
▸ delete():Promise<APIChannel>
Deletes the channel
Returns
Promise<APIChannel>
Promise that resolves to the deleted channel
Defined in
src/structures/Channel.ts:149edit
▸ edit(data): Promise<APIChannel>
Edits the channel
Parameters
| Name | Type | Description |
|---|---|---|
data | RESTPatchAPIChannelJSONBody | The data used to edit the channel |
Returns
Promise<APIChannel>
Promise that resolves to the edited channel
Defined in
src/structures/Channel.ts:159editMessage
▸ editMessage(messageId, data): Promise<APIMessage>
Edits a message.
Parameters
| Name | Type | Description |
|---|---|---|
messageId | string | The ID of the message to be edited. |
data | RESTPatchAPIChannelMessageJSONBody & { files?: RawFile[] } | The data to be updated in the message. |
Returns
Promise<APIMessage>
- A promise that resolves to the edited message.
Defined in
src/structures/Channel.ts:84fetchMessage
▸ fetchMessage(messageId): Promise<APIMessage>
Fetches a specific message by its ID.
Parameters
| Name | Type | Description |
|---|---|---|
messageId | string | The ID of the message to fetch. |
Returns
Promise<APIMessage>
A Promise that resolves to the fetched message.
Defined in
src/structures/Channel.ts:97fetchMessages
▸ fetchMessages(data): Promise<APIMessage[]>
Fetches messages using the provided data.
Parameters
| Name | Type | Description |
|---|---|---|
data | RESTGetAPIChannelMessagesQuery | The data used to fetch messages. |
Returns
Promise<APIMessage[]>
A promise that resolves to an array of API messages.
Defined in
src/structures/Channel.ts:107getInvites
▸ getInvites():Promise<APIInvite[]>
Retrieves the invites.
Returns
Promise<APIInvite[]>
The list of invites.
Defined in
src/structures/Channel.ts:140getWebhooks
▸ getWebhooks():Promise<Webhook[]>
Gets all webhooks in the current channel or parent channel (if a thread)
Returns
Promise<Webhook[]>
A promise that resolves with an array of webhooks.
Defined in
src/structures/Channel.ts:305isDMBased
▸ isDMBased():boolean
Determines if the channel is DM-based.
Returns
boolean
- True if the channel is DM-based, false otherwise.
Defined in
src/structures/Channel.ts:254isTextBased
▸ isTextBased():boolean
Checks if the function is text-based.
Returns
boolean
true if the function is text-based, false otherwise.
Defined in
src/structures/Channel.ts:245isThread
▸ isThread():boolean
Checks if the channel type is a thread.
Returns
boolean
true if the channel type is a thread, false otherwise
Defined in
src/structures/Channel.ts:221isVoiceBased
▸ isVoiceBased():boolean
Determines if the channel is voice-based.
Returns
boolean
Returns true if the channel is voice-based, false otherwise.
Defined in
src/structures/Channel.ts:234pinMessage
▸ pinMessage(messageId): Promise<void>
Pin a message
Parameters
| Name | Type | Description |
|---|---|---|
messageId | string | The data used to pin a message |
Returns
Promise<void>
Promise that resolves when the message is pinned
Defined in
src/structures/Channel.ts:179send
▸ send(data): Promise<APIMessage>
Sends a message with the given data.
Parameters
| Name | Type | Description |
|---|---|---|
data | RESTPostAPIChannelMessageJSONBody & { files?: RawFile[] } | The data for the message. |
Returns
Promise<APIMessage>
A promise that resolves to the created message.
Defined in
src/structures/Channel.ts:71toString
▸ toString(): `<#${string}>` Returns a string representation of the channel.Returns
`<#${string}>` The string representation of the channel.Defined in
src/structures/Channel.ts:263unpinMessage
▸ unpinMessage(messageId): Promise<void>
Unpin a message
Parameters
| Name | Type | Description |
|---|---|---|
messageId | string | The data used to unpin a message |
Returns
Promise<void>
Promise that resolves when the message is unpinned
