The guides for D.js and Sapphire seem pretty sparse, but some of the better docs can be found at:
- Getting Started: https://deploy-preview-711--discordjs-guide.netlify.app/sapphire/
- Other resources hopefully coming soon?
- @sapphire/framework
- @sapphire/utilities
- @sapphire/plugin-editable-commands
- @sapphire/plugin-api
- @sapphire/plugin-logger
- @sapphire/plugin-subcommands
npm install- Set up your
.env.localfile (see below) - In VS Code, hit F5 to start up with debugging & hot reloading. Alternatively, you can use
npm run watch:startto run it via CLI.
At a minimum .env.local must include BUSTER_BOT_TOKEN. Optionally, it can include other fields overriding things in .env.development or where necessary as documented in .env.example.
Minimum .env.local:
# Bot Token (Vault)
BUSTER_BOT_TOKEN=
The bot is currently reliant on a config.json either hosted at a URL or on the filesystem. The minimum config looks something like:
{
"owners": [123456...],
}I'm gonna be honest, this bot relies on a lot of magic behind the scenes (which I'm personally not a fan of). This section hopes to unmistify some of that magic.
Should contain general configs, including:
.envfile(s)Dockerfilefor container builds.dockerignoredata/config.jsonfor bot config (unless a URL is specified)- Any other config files or DB's
Where the code is located, with index.ts being the main file and setup.ts being any code that is ran immediately upon launch.
Where command files are placed. Files can be placed directly in the commands/ directory (//TODO: Fact check this), or in subdirectories to categorize them.
Very basic command template:
import { ApplyOptions } from "@sapphire/decorators";
import { Command, CommandOptions } from "@sapphire/framework";
import type { Message } from "discord.js";
@ApplyOptions<CommandOptions>({
description: "ping pong",
})
export class UserCommand extends Command {
public async run(message: Message) {
return message.channel.send("Pong!");
}
}Utility and shared components used in the rest of the application. It is possible the contents of this directory will be reduced into the root src/ folder to simplify things later.
Event listener code. Honestly, I'm still not entirely sure how these work, but the gist is that these work in a similar way to that of commands, except they listen for other events listed here.
Precondition code. Once again, not entirely sure how this works, but it seems to be code that gets called before commands, determining whether or not they're allowed to run.
Code for handling HTTP API requests. Although unused now, this could be a great way to write web integrations with CF Workers, Pages, and/or maybe some sort of file hosting?
Data folder for holding database files, configs, or static assets