Yor.ts | classes/Channel
Class: Channel
Hierarchy
-
↳
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
Throws
If channel data is not provided.
Overrides
Defined in
Properties
API
• Private
API: ChannelsAPI
Defined in
client
• client: YorClient
Inherited from
Defined in
flags
• Optional
flags: ChannelFlags
Defined in
id
• id: string
Defined in
name
• name: undefined
| string
Defined in
raw
• raw: Partial
<APIChannel
>
Defined in
type
• type: number
Defined in
Methods
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
createInvite
▸ 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
createWebhook
▸ 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
A promise that resolves with the created webhook.
Defined in
createdAt
▸ createdAt(): Date
Returns the creation date of the object.
Returns
The creation date of the object.
Defined in
createdTimestamp
▸ createdTimestamp(): number
Returns the created timestamp as a Date object.
Returns
number
The created timestamp.
Defined in
crosspostMessage
▸ 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
delete
▸ delete(): Promise
<APIChannel
>
Deletes the channel
Returns
Promise
<APIChannel
>
Promise that resolves to the deleted channel
Defined in
edit
▸ 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
editMessage
▸ 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
fetchMessage
▸ 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
fetchMessages
▸ 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
getInvites
▸ getInvites(): Promise
<APIInvite
[]>
Retrieves the invites.
Returns
Promise
<APIInvite
[]>
The list of invites.
Defined in
getWebhooks
▸ getWebhooks(): Promise
<Webhook
[]>
Gets all webhooks in the current channel or parent channel (if a thread)
Returns
A promise that resolves with an array of webhooks.
Defined in
isDMBased
▸ isDMBased(): boolean
Determines if the channel is DM-based.
Returns
boolean
- True if the channel is DM-based, false otherwise.
Defined in
isTextBased
▸ isTextBased(): boolean
Checks if the function is text-based.
Returns
boolean
true if the function is text-based, false otherwise.
Defined in
isThread
▸ isThread(): boolean
Checks if the channel type is a thread.
Returns
boolean
true if the channel type is a thread, false otherwise
Defined in
isVoiceBased
▸ isVoiceBased(): boolean
Determines if the channel is voice-based.
Returns
boolean
Returns true if the channel is voice-based, false otherwise.
Defined in
pinMessage
▸ 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
send
▸ 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
toString
▸ toString(): `<#${string}>`
Returns a string representation of the channel.
Returns
`<#${string}>`
The string representation of the channel.
Defined in
unpinMessage
▸ 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
Defined in
Was this page helpful?