Carbon

Client

The main class that is used to use Carbon

The main class that is used to use Carbon is the Client class. Everything all connects to this one class, and it is the main instance for your bot.

Creating a Client

A client must be created within your createHandle factory.

src/index.ts
const handle = createHandle((env) => {
    const client = new Client({
        baseUrl: String(env.BASE_URL),
        deploySecret: String(env.DEPLOY_SECRET),
        clientId: String(env.CLIENT_ID),
        publicKey: String(env.PUBLIC_KEY),
        token: String(env.TOKEN),
    }, [new PingCommand()])
    return [client]
})

Here we have created a client with the following options:

  • baseUrl: The relative base URL of your app
  • deploySecret: The deploy secret of your bot, used as a password for deploying commands and other sensitive matters
  • clientId: The Discord client ID of your bot
  • publicKey: The Discord public key of your bot
  • token: The Discord token of your bot

And we have also provided it with a list of commands, which in this case is just the PingCommand we created earlier.

Last updated on

On this page

Edit on GitHub