Skip to content

Channel

Package: @erinjs/core

Base class for all channel types.

Constructor

NameTypeOptionalDescription
clientClientNo
dataAPIChannelPartialNoAPI channel from GET /channels/{id} or GET /guilds/{id}/channels

Properties

NameTypeReadonlyOptionalDescription
clientClientYesNo
iconstring | nullNoNoChannel icon hash (Group DMs). Null if none.
idstringYesNo
lastPinTimestampstring | nullNoNoISO timestamp when the last message was pinned. Null if never pinned.
namestring | nullNoNoChannel name. Guild channels and Group DMs have names; 1:1 DMs are typically null.
typeChannelTypeNoNo

Methods

bulkDeleteMessages() async

Bulk delete messages. Requires Manage Messages permission.

Returns: Promise<void>

Parameters:

NameTypeOptionalDescription
messageIdsstring[]NoArray of message IDs to delete (2–100)

canSendMessage()

Whether the bot can send messages in this channel. For DMs: always true (when the channel exists). For guild channels: checks ViewChannel and SendMessages permissions via guild.members.me.

Returns: boolean

Parameters:

None


createDM()

Create a DM channel from API data (type DM or GroupDM).

Returns: DMChannel

Parameters:

NameTypeOptionalDescription
clientClientNo
dataAPIChannelPartialNo

from()

Create the appropriate channel subclass from API data.

Returns: GuildChannel | TextChannel | null

Parameters:

NameTypeOptionalDescription
clientClientNoThe client instance
dataanyNoChannel data from the API

fromOrCreate()

Create a channel from API data, including DM and GroupDM. Used by ChannelManager.fetch() for GET /channels/{id}.

Returns: DMChannel | GuildChannel | TextChannel | null

Parameters:

NameTypeOptionalDescription
clientClientNo
dataanyNo

isDM()

Whether this channel is a DM or Group DM.

Returns: boolean

Parameters:

None


Returns: boolean

Parameters:

None


isTextBased()

Whether this channel has a send method (TextChannel, DMChannel).

Returns: boolean

Parameters:

None


isVoice()

Whether this channel is voice-based (VoiceChannel).

Returns: boolean

Parameters:

None


sendTyping() async

Send a typing indicator to the channel. Lasts ~10 seconds.

Returns: Promise<void>

Parameters:

None

Released under the Apache-2.0 License.