LogoLogo
  • What is WildBeast?
  • Guides
    • Linux guides
      • Setup
      • Running as a service
  • Fundamentals
    • Commands
      • Slash commands
        • Subcommands
        • Options
        • Buttons
      • Context menu actions
    • Jobs
  • Extras
    • VPS recommendations
    • Creating a bot account
    • Adding your bot to your server
Powered by GitBook
On this page
  • Creating commands
  • In practice
  • What's next?

Was this helpful?

Export as PDF
  1. Fundamentals
  2. Commands

Slash commands

Slash commands are the primary way to interact with bots

PreviousCommandsNextSubcommands

Last updated 3 years ago

Was this helpful?

Creating commands

Reminder: Check the for more advanced settings.

A finished command looks like this:

import { Interaction } from 'detritus-client'
import { BaseSlashCommand } from '../base'

export default class PingCommand extends BaseSlashCommand {
  constructor () {
    super({
      description: 'Ping',
      name: 'ping'
    })
  }

  async run (context: Interaction.InteractionContext): Promise<void> {
    await context.editOrRespond(context, 'Pong!')
  }
}

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:

constructor () {
  super({
    description: 'Ping',
    name: 'ping',
    guildIds: ['110462143152803840']
  })
}

What's next?

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

Subcommands
Options
Buttons
Detritus Documentation