yor.ts / Exports / Channel

Class: Channel

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Channel(client, data): Channel Constructs a new instance of the class.

Parameters

NameTypeDescription
clientYorClientThe client object.
dataundefined | { 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.constructor

Defined in

src/structures/Channel.ts:45

Properties

API

Private API: ChannelsAPI

Defined in

src/structures/Channel.ts:36

client

client: YorClient

Inherited from

Base.client

Defined in

src/structures/Base.ts:4

flags

Optional flags: ChannelFlags

Defined in

src/structures/Channel.ts:32

id

id: string

Defined in

src/structures/Channel.ts:29

name

name: undefined | string

Defined in

src/structures/Channel.ts:30

raw

raw: Partial<APIChannel>

Defined in

src/structures/Channel.ts:34

type

type: number

Defined in

src/structures/Channel.ts:31

Methods

bulkDeleteMessages

bulkDeleteMessages(messages): Promise<void> Bulk deletes messages

Parameters

NameTypeDescription
messagesstring[]The data used to bulk delete messages

Returns

Promise<void> Promise that resolves when the messages are deleted

Defined in

src/structures/Channel.ts:169

createInvite

createInvite(data): Promise<APIInvite> Creates an invite using the given data and returns the created invite.

Parameters

NameTypeDescription
dataRESTPostAPIChannelInviteJSONBodyThe data used to create the invite.

Returns

Promise<APIInvite> The created invite.

Defined in

src/structures/Channel.ts:129

createWebhook

createWebhook(data): Promise<Webhook> Creates a webhook in the current channel or parent channel (if a thread) with the given data

Parameters

NameTypeDescription
dataRESTPostAPIChannelWebhookJSONBody & { 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:274

createdAt

createdAt(): Date Returns the creation date of the object.

Returns

Date The creation date of the object.

Defined in

src/structures/Channel.ts:212

createdTimestamp

createdTimestamp(): number Returns the created timestamp as a Date object.

Returns

number The created timestamp.

Defined in

src/structures/Channel.ts:198

crosspostMessage

crosspostMessage(messageId): Promise<APIMessage> Crossposts a message.

Parameters

NameTypeDescription
messageIdstringThe ID of the message to crosspost.

Returns

Promise<APIMessage> A promise that resolves to the crossposted message.

Defined in

src/structures/Channel.ts:119

delete

delete(): Promise<APIChannel> Deletes the channel

Returns

Promise<APIChannel> Promise that resolves to the deleted channel

Defined in

src/structures/Channel.ts:149

edit

edit(data): Promise<APIChannel> Edits the channel

Parameters

NameTypeDescription
dataRESTPatchAPIChannelJSONBodyThe data used to edit the channel

Returns

Promise<APIChannel> Promise that resolves to the edited channel

Defined in

src/structures/Channel.ts:159

editMessage

editMessage(messageId, data): Promise<APIMessage> Edits a message.

Parameters

NameTypeDescription
messageIdstringThe ID of the message to be edited.
dataRESTPatchAPIChannelMessageJSONBody & { 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:84

fetchMessage

fetchMessage(messageId): Promise<APIMessage> Fetches a specific message by its ID.

Parameters

NameTypeDescription
messageIdstringThe ID of the message to fetch.

Returns

Promise<APIMessage> A Promise that resolves to the fetched message.

Defined in

src/structures/Channel.ts:97

fetchMessages

fetchMessages(data): Promise<APIMessage[]> Fetches messages using the provided data.

Parameters

NameTypeDescription
dataRESTGetAPIChannelMessagesQueryThe data used to fetch messages.

Returns

Promise<APIMessage[]> A promise that resolves to an array of API messages.

Defined in

src/structures/Channel.ts:107

getInvites

getInvites(): Promise<APIInvite[]> Retrieves the invites.

Returns

Promise<APIInvite[]> The list of invites.

Defined in

src/structures/Channel.ts:140

getWebhooks

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:305

isDMBased

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:254

isTextBased

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:245

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

src/structures/Channel.ts:221

isVoiceBased

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:234

pinMessage

pinMessage(messageId): Promise<void> Pin a message

Parameters

NameTypeDescription
messageIdstringThe data used to pin a message

Returns

Promise<void> Promise that resolves when the message is pinned

Defined in

src/structures/Channel.ts:179

send

send(data): Promise<APIMessage> Sends a message with the given data.

Parameters

NameTypeDescription
dataRESTPostAPIChannelMessageJSONBody & { files?: RawFile[] }The data for the message.

Returns

Promise<APIMessage> A promise that resolves to the created message.

Defined in

src/structures/Channel.ts:71

toString

toString(): `<#${string}>` Returns a string representation of the channel.

Returns

`<#${string}>` The string representation of the channel.

Defined in

src/structures/Channel.ts:263

unpinMessage

unpinMessage(messageId): Promise<void> Unpin a message

Parameters

NameTypeDescription
messageIdstringThe data used to unpin a message

Returns

Promise<void> Promise that resolves when the message is unpinned

Defined in

src/structures/Channel.ts:189