Basic Usage
How to set up and configure a Carbon project, including both automatic and manual setup methods.
Automatic Setup
We recommend starting a new Carbon project using create-carbon
, which will set everything up automatically for you. To create a project, run:
You'll be prompted to enter a project name, select a runtime, and configure some other options. Once you've answered all the questions, create-carbon
will generate a new project for you.
Manual Setup
If you prefer to set up a Carbon project manually, follow the steps below:
Set Up a TypeScript Project
First, set up a new TypeScript project. You can follow the official TypeScript Handbook for detailed instructions on how to get started.
Create a Client and Handle Function
Next, create a handle function by passing a client factory to the createHandle
function. The factory should return an array of plugins, the first being the client, and the rest being any other optional plugins you may want to add.
Setting environment variables will be covered in a later step.
Create a Command
Now we'll create a simple command that responds with "Hello!" when invoked. This command will serve as a basic example to demonstrate how to set up and handle interactions with your bot.
Then, mount the command to your client to make it available for use. This step involves importing the command and adding it to the client's configuration.
Use an Adapter
You'll now need to set up an adapter to wrap your handle function to work with your runtime, pick an adapter from the list below to continue.
Cloudflare Workers
Deploy your Carbon bot using Cloudflare Workers for a scalable, serverless environment.
Next.js
Integrate your Carbon bot with a Next.js application for seamless server-side rendering.
Node.js
Deploy your Carbon bot using Node.js for a flexible and robust server environment.
Bun
Run your Carbon bot with Bun for a fast and lightweight alternative to Node.js.
Last updated on