Skip to content

command

command<M>(definition): Command<M>

Defined in: packages/core/src/commands.ts:413

Defines a command once; it can be a slash command, a prefix command, or both.

M extends OptionMap = Record<never, never>

CommandDefinition<M>

Command<M>

export default command({
name: "timeout",
description: "Time a member out",
permissions: ["ModerateMembers"],
options: {
user: option.user({ required: true }),
minutes: option.integer({ min: 1, max: 40_320, default: 10 }),
reason: option.string({ max: 500 }),
},
prefix: true,
async run({ bot, options, guildId, reply }) {
await bot.member(guildId!, options.user).timeout(`${options.minutes}m`, options.reason);
await reply(`Timed out <@${options.user}>.`);
},
});

For a name, description or option Discord would refuse.

If it is neither a slash nor a prefix command, or a required option follows an optional one.