Search…
Slash commands
Slash commands are the primary way to interact with bots

Creating commands

Reminder: Check the Detritus Documentation for more advanced settings.
A finished command looks like this:
1
import { Interaction } from 'detritus-client'
2
import { BaseSlashCommand } from '../base'
3
4
export default class PingCommand extends BaseSlashCommand {
5
constructor () {
6
super({
7
description: 'Ping',
8
name: 'ping'
9
})
10
}
11
12
async run (context: Interaction.InteractionContext): Promise<void> {
13
await context.editOrRespond(context, 'Pong!')
14
}
15
}
16
Copied!
There are a few things to note with regard to how commands are constructed:
  • All commands are new classes that extend a base class, in this example the command is a plain slash command.
  • The resulting command is exported as the default export.
  • The constructor with a super call is used to set properties of the class instead of directly assigning them, this avoids incompatibilities with Detritus.

In practice

When restarting WildBeast, your newly created command will automatically be registered as a global command, and will be available within a few hours.
Rather want a guild-based command instead of a global one? Add guild IDs to the constructor of your command:
1
constructor () {
2
super({
3
description: 'Ping',
4
name: 'ping',
5
guildIds: ['110462143152803840']
6
})
7
}
Copied!

What's next?

There are more things you can do with commands, like adding options, creating subcommands, and adding buttons and select menus.
Export as PDF
Copy link