Carbon
Core/Classes

Client

The main client used to interact with Discord

Constructors

Constructor

new Client(options, handlers, plugins): Client

Creates a new client

Parameters

ParameterTypeDefault valueDescription
optionsClientOptionsundefinedThe options used to initialize the client
handlers{ commands: BaseCommand[]; listeners: BaseListener[]; }undefinedThe handlers that the client has registered
handlers.commands?BaseCommand[]undefined-
handlers.listeners?BaseListener[]undefined-
pluginsPlugin[][]The plugins that the client should use

Returns

Client

Properties

PropertyTypeDefault valueDescription
commandHandlerCommandHandlerundefinedInternal The handler for the modal interactions sent from Discord
commandsBaseCommand[]undefinedThe commands that the client has registered
componentHandlerComponentHandlerundefinedInternal The handler for the component interactions sent from Discord
eventHandlerEventHandlerundefinedInternal The handler for events sent from Discord
listenersBaseListener[][]The event listeners that the client has registered
modalHandlerModalHandlerundefinedInternal The handler for the modal interactions sent from Discord
optionsClientOptionsundefinedThe options used to initialize the client
pluginsPlugin[][]The plugins that the client has registered
restRequestClientundefinedThe rest client used to interact with the Discord API
routesRoute[][]The routes that the client will handle

Methods

fetchChannel()

fetchChannel(id): Promise<null | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildCategoryChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>

Fetch a channel from the Discord API

Parameters

ParameterTypeDescription
idstringThe ID of the channel to fetch

Returns

Promise<null | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildCategoryChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>

The channel data


fetchGuild()

fetchGuild(id): Promise<Guild<false>>

Fetch a guild from the Discord API

Parameters

ParameterTypeDescription
idstringThe ID of the guild to fetch

Returns

Promise<Guild<false>>

The guild data


fetchMember()

fetchMember(guildId, id): Promise<GuildMember<false, true>>

Fetch a member from the Discord API

Parameters

ParameterTypeDescription
guildIdstringThe ID of the guild the member is in
idstringThe ID of the member to fetch

Returns

Promise<GuildMember<false, true>>

The member data


fetchMessage()

fetchMessage(channelId, messageId): Promise<Message<false>>

Fetch a message from the Discord API

Parameters

ParameterTypeDescription
channelIdstringThe ID of the channel the message is in
messageIdstringThe ID of the message to fetch

Returns

Promise<Message<false>>

The message data


fetchRole()

fetchRole(guildId, id): Promise<Role<false>>

Fetch a role from the Discord API

Parameters

ParameterTypeDescription
guildIdstring-
idstringThe ID of the role to fetch

Returns

Promise<Role<false>>

The role data


fetchUser()

fetchUser(id): Promise<User<false>>

Fetch a user from the Discord API

Parameters

ParameterTypeDescription
idstringThe ID of the user to fetch

Returns

Promise<User<false>>

The user data


handleDeployRequest()

handleDeployRequest(): Promise<Response>

Handle a request to deploy the commands to Discord

Returns

Promise<Response>

A response


handleEventsRequest()

handleEventsRequest(req): Promise<Response>

Handle an interaction request from Discord

Parameters

ParameterTypeDescription
reqRequestThe request to handle

Returns

Promise<Response>

A response


handleInteractionsRequest()

handleInteractionsRequest(req, ctx): Promise<Response>

Handle an interaction request from Discord

Parameters

ParameterTypeDescription
reqRequestThe request to handle
ctxContextThe context for the request

Returns

Promise<Response>

A response

On this page