Skip to content
GitHub

MessageHandlerOptions

interface in meocord/interface Since 4.1.0

interface MessageHandlerOptions

What one message command sets for itself, over the app's messages options.

Use it to give a command its own prefix or case, aliases, a description for a help listing, or the places it works. The app-wide defaults are MessageCommandOptions.

Examples

TypeScript
@MessageHandler('mute {target:member} {duration:duration?}', {
  aliases: ['m'],
  description: 'Times a member out.',
  scope: 'guild',
})
async mute(message: Message, { target, duration }: { target: GuildMember; duration?: number }) {
  await target.timeout(duration ?? 600_000)
}

Members

prefix

prefix?: false | MessagePrefix

The handler's own prefixes, in place of the app's; a mention of the bot still counts when the app accepts one. false matches the message as it is, with no prefix or mention. Where a message also fits a handler with the same pattern that takes the app's prefixes, as it can when the app's prefix is a function, this handler runs, whatever order the controllers are listed in.

mention

mention?: 'only'

'only' starts the command in a server with a mention of the bot and nothing else, whatever the app's prefixes, so it needs no MessageContent intent. In a direct message it starts as usual, after its own prefix or the app's.

caseSensitive

caseSensitive?: boolean

Overrides the app's caseSensitive for this handler.

aliases

aliases?: readonly string[]

Other words for the command, each in place of the words the pattern begins with: with ['b'], ban {target:member} also takes !b @ana. HandlerRegistry lists the handler once, with its aliases.

description

description?: string

What the command does, shown by the built-in help and by HandlerRegistry.

scope

scope?: MessageScope

Where the command works; 'any' by default. A message sent elsewhere gets a usage reply saying where it works, and the handler does not run. A command with a member, role or channel param works in servers only; 'dm' with one is refused as the bot starts.

hidden

hidden?: boolean

Leaves the command out of the built-in help's list and of a parent's list of subcommands. It is not a secret: it still runs, a misuse still gets its usage, and !help <command> still shows it when named.

Default: false

See also

  • MessageHandler
  • Message commands