Subcommands
Nest multiple separate commands under one base command
Last updated
Was this helpful?
Nest multiple separate commands under one base command
Last updated
Was this helpful?
Was this helpful?
import { Interaction } from 'detritus-client'
import { BaseSlashCommand, BaseCommandOption } from '../base'
export default class PingCommand extends BaseSlashCommand {
constructor () {
super({
name: 'ping',
// With subcommands, the description doesn't matter,
// since it doesn't get shown to end users.
description: '',
options: [
new PongCommand()
]
})
}
// The base command should not have a run(), it never gets called
}
export class PongCommand extends BaseCommandOption {
constructor () {
super({
name: 'pong'
description: 'Pong!'
})
}
async run (context: Interaction.InteractionContext): Promise<void> {
await context.editOrRespond(context, 'Pong!')
}
}