Skip to content

Quickstart

Bostie typing code into a terminal

This page creates a Discord application, adds it to a server and runs a bot with one slash command. It assumes bostie is installed.

Using an AI coding assistant?

Install the bostie skill to make your coding assistant better at bostie tasks. Copy the prompt and paste it into your coding assistant. More about the skill

Install the bostie skill
Install the bostie skill for my coding agent so it writes correct bostie code: Discord bots with slash commands, components, events, REST calls, voice and tests.

Use the Agent Skills installer with the bostie repository, https://github.com/nicokim/bostie:

    npx skills add nicokim/bostie --skill bostie --yes

If I ask for a global install instead, use:

    npx skills add nicokim/bostie --skill bostie --yes --global

Detect which agent or editor I am using. If it is one of these and I prefer the plugin path, install the bostie plugin instead, as https://bostie.dev/assistants/ shows:

    Claude Code: /plugin marketplace add nicokim/bostie, then /plugin install bostie@bostie
    Codex CLI: codex plugin marketplace add nicokim/bostie, then codex plugin add bostie@bostie
    GitHub Copilot CLI: copilot plugin marketplace add nicokim/bostie, then copilot plugin install bostie@bostie
    VS Code with GitHub Copilot: run "Chat: Install Plugin from Source" and enter nicokim/bostie
    Devin: devin plugins install nicokim/bostie#docs
    Factory Droid: droid plugin marketplace add nicokim/bostie, then droid plugin install bostie@bostie --scope user
    Qwen Code: qwen extensions install nicokim/bostie:bostie

Do not invent other skill names or install URLs.

Then add this line to the instructions file you read at the start of every session (AGENTS.md at the project root, or your global one for a global install), and create the file if needed:

    Before you write or change code that uses bostie, look at how the project is laid out, then load the bostie skill.

After installing, confirm that the bostie skill is available to you.

Create the application

  1. Open the Developer Portal and create an application.
  2. On its Bot page, reset the token and copy it. Anyone with the token controls the bot, so keep it out of your code and your repository.
  3. On its Installation page, add the applications.commands and bot scopes to the guild install, then open the install link and add the app to a server you manage.

Write the bot

Save this as bot.py:

import bostie
from bostie import Context

bot = bostie.Bot()


@bot.command
async def hello(ctx: Context) -> None:
    """Say hello."""
    await ctx.respond(f"Hello, {ctx.user.display_name}!")


bot.run()

@bot.command turns the function into the slash command /hello. Its name is the function's name and its description is the first line of the docstring. ctx is the Context of one use of the command: who ran it, where, and the methods that answer.

Run it

Pass the token through the BOSTIE_TOKEN environment variable and start the file:

export BOSTIE_TOKEN="your token"
python bot.py

bot.run() sets up logging at INFO, connects, and compares the commands you defined with those registered on Discord. The first start registers /hello and logs commands synced (global): added ['hello'], ...; later starts send nothing unless a command changed. Type /hello in your server and the bot answers.

Ctrl+C, or a SIGTERM from a process manager, closes the bot cleanly.

Add an option

Parameters after ctx become the command's options, typed by their hints:

import secrets

import bostie
from bostie import Context, Range

bot = bostie.Bot()


@bot.command
async def roll(ctx: Context, sides: Range[int, 2, 100] = 6) -> None:
    """Roll a die."""
    rolled = secrets.randbelow(sides) + 1
    await ctx.respond(f"You rolled {rolled} on a d{sides}.")


bot.run()

sides is an integer option from 2 to 100 that defaults to 6, so Discord shows it as optional and refuses values outside the range before the bot sees them. Restart the bot and it sends the changed command.

Next

  • Slash commands covers every option type, choices, autocomplete and subcommands.
  • Answering interactions explains respond, deferring, follow-ups and ephemeral answers.
  • Registering commands shows how to register commands in one test server while you work on them.
  • Running a bot covers the token, logging, the bot's lifecycle and running it inside another program.