ceejay.channels
List the channels of your Discord server, to find the one to post to.
The function takes the same last argument as every other, options: signal, timeoutMs
and maxRetries, for that one call. It can also raise the errors any request can raise,
such as a bad key or the rate limit. Both are on
Errors and retries.
ceejay.channels.list
Lists the text, announcement and forum channels of your server and its categories, in Discord's order. Voice, stage and thread channels are left out.
GET /v1/channels · requires messages:send · API reference: List channels
Retried by the SDK: Yes. It is a read
Takes options only.
Returns the full response, typed as Schemas['ListChannelsResponse']. The channels are
in data, and page is alongside it.
Prop
Type
Each channel, typed as Schemas['Channel']:
Prop
Type
sendable is about the kind of channel. Whether the bot has permission in one channel
cannot be told from the list: ceejay.messages.send reports it when you post.
CEEJAY reads the list from Discord and caches it for up to a minute. Never returned: topics, permission settings, slow-mode settings or members.
Errors
A list that could not be read is an error, never an empty list.
| Status | code | When |
|---|---|---|
429 | discord_rate_limited | Discord is limiting the bot. retryAfter is the wait Discord specified, when it gave one |
500 | discord_not_configured | This instance cannot reach Discord yet |
503 | channels_unavailable | The channels could not be read from Discord. Retry with backoff |
Example
const channels = await ceejay.channels.list()
const postable = channels.data.filter((channel) => channel.sendable && !channel.private)
for (const channel of postable) {
console.log(channel.channelId, `#${channel.name}`)
}
