Skip to content

ChannelManager

Package: @erinjs/core

Manages channels with fetch and send. Extends Collection so you can use .get(), .set(), .filter(), etc.

Constructor

NameTypeOptionalDescription
clientClientNo

Properties

NameTypeReadonlyOptionalDescription
maxSizenumberYesNo

Methods

fetch() async

Fetch a channel by ID from the API (or return from cache if present).

Returns: Promise<Channel>

Parameters:

NameTypeOptionalDescription
channelIdstringNoSnowflake of the channel

fetchMessage() async

Fetch a message by ID from the API.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
channelIdstringNoSnowflake of the channel
messageIdstringNoSnowflake of the message

resolve() async

Get a channel from cache or fetch from the API if not present. Convenience helper to avoid repeating client.channels.get(id) ?? (await client.channels.fetch(id)).

Returns: Promise<Channel>

Parameters:

NameTypeOptionalDescription
channelIdstringNoSnowflake of the channel

send() async

Send a message to a channel by ID. Works even when the channel is not cached. Skips the fetch when you only need to send.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
channelIdstringNoSnowflake of the channel (text channel or DM)
payloadstring | MessageSendOptionsNoText content or object with content, embeds, and/or files

set()

Returns: this

Parameters:

NameTypeOptionalDescription
keystringNo
valueChannelNo

Released under the Apache-2.0 License.