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.
Type Parameters
Section titled “Type Parameters”M extends OptionMap = Record<never, never>
Parameters
Section titled “Parameters”definition
Section titled “definition”Returns
Section titled “Returns”Command<M>
Example
Section titled “Example”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}>.`); },});Throws
Section titled “Throws”For a name, description or option Discord would refuse.
Throws
Section titled “Throws”If it is neither a slash nor a prefix command, or a required option follows an optional one.