Slash Commands

For most bots, Slash Commands will be the bread and butter of their bot's features. Its usage is very basic but can be extended by Options to accept user input and change the response.

These commands live in the commands directory, and use the defineSlashCommand Definition Function for type support.

TIP

For more advanced uses, visit the Setup Method guide.

Basic Command

import { defineSlashCommand } from 'chooksie'

export default defineSlashCommand({
  name: 'ping',
  description: 'Pong!',
  async execute(ctx) {
    await ctx.interaction.reply('Pong!')
  },
})
import { defineSlashCommand } from 'chooksie'

export default defineSlashCommand({
  name: 'ping',
  description: 'Pong!',
  async execute(ctx) {
    await ctx.interaction.reply('Pong!')
  },
})
const { defineSlashCommand } = require('chooksie')

module.exports = defineSlashCommand({
  name: 'ping',
  description: 'Pong!',
  async execute(ctx) {
    await ctx.interaction.reply('Pong!')
  },
})

With Options

import { defineSlashCommand } from 'chooksie'

export default defineSlashCommand({
  name: 'echo',
  description: 'Echoes what you just said.',
  async execute(ctx) {
    const message = ctx.interaction.options.getString('message', true)
    await ctx.interaction.reply(message)
  },
  options: [
    {
      name: 'message',
      description: 'The message to repeat.',
      type: 'STRING',
      required: true,
    },
  ],
})
import { defineSlashCommand } from 'chooksie'

export default defineSlashCommand({
  name: 'echo',
  description: 'Echoes what you just said.',
  async execute(ctx) {
    const message = ctx.interaction.options.getString('message', true)
    await ctx.interaction.reply(message)
  },
  options: [
    {
      name: 'message',
      description: 'The message to repeat.',
      type: 'STRING',
      required: true,
    },
  ],
})
const { defineSlashCommand } = require('chooksie')

module.exports = defineSlashCommand({
  name: 'echo',
  description: 'Echoes what you just said.',
  async execute(ctx) {
    const message = ctx.interaction.options.getString('message', true)
    await ctx.interaction.reply(message)
  },
  options: [
    {
      name: 'message',
      description: 'The message to repeat.',
      type: 'STRING',
      required: true,
    },
  ],
})