Getting started: your first bot

This page walks through creating a bot, getting its token, and inviting it to a server. It takes about two minutes.

1. Create the bot

Open Settings → Bots in Disband and click New bot.

Disband returns a token, shown once. Copy it somewhere safe now: it is never shown again and cannot be retrieved later. If you lose it, revoke the bot and create a new one.

The token is what your code uses to authenticate:

Authorization: Bot <token>

2. Invite the bot to a server

In Settings → Bots, open the bot you just created:

  1. Click Generate invite.
  2. Pick the target server and the scope set to grant.
  3. Send the resulting link to that server's owner.

Only the owner can approve a bot invite. Invites expire after 7 days.

3. The owner approves

The owner opens the link and clicks Approve. The bot becomes a member of the server, limited to the scopes that were approved. (The approved scopes are the intersection of the bot account's scopes and what the owner granted — you cannot approve more than the bot was created with.)

4. Connect with a client

Save the token to an environment variable and run one of the clients:

// JavaScript — install with: npm install /path/to/packages/bot
import { Client } from "@disband/bot";

const client = new Client({ token: process.env.DISBAND_BOT_TOKEN });

client.on("messageCreate", async (message) => {
  if (message.author?.is_bot) return;
  if (message.content !== "!ping") return;
  await message.reply("pong");
});

await client.connect();
# Python — install with: pip install ./packages/disband-bot-python
from disband_bot import Client

client = Client(token=DISBAND_BOT_TOKEN)

@client.on("messageCreate")
def handle(message):
    if message.author_is_bot:
        return
    if message.content == "!ping":
        message.reply("pong")

client.run()

The client connects to the gateway, fires ready, and then streams message events. See JavaScript and Python for the full API.

What's next