MessageCommand class

Represents a Discord Message Command.

MessageCommands are commands that can be invoked on a target message from the Discord client.

For example, a simple command that replies to the target message:

MessageCommand test = MessageCommand(
  'Test',
  (MessageContext context) {
    context.respond(
      MessageBuilder()
        ..content = 'This was the target message!'
        ..replyBuilder = ReplyBuilder.fromMessage(context.targetMessage),
    );
  },
);

commands.addCommand(test);

You might also be interested in:

Implemented types

Constructors

MessageCommand(String name, dynamic execute(MessageContext), {Iterable<AbstractCheck> checks = const [], CommandOptions options = const CommandOptions(), Map<Locale, String>? localizedNames})
Create a new MessageCommand.

Properties

checks Iterable<AbstractCheck>
The checks that should be applied to this entity.
no setterinherited
execute → dynamic Function(MessageContext)
The function called to execute this command.
final
hashCode int
The hash code for this object.
no setterinherited
localizedNames Map<Locale, String>?
The localized names of this child. Since you cannot add descriptions to UserCommand and MessageCommand, can't set localized descriptions too.
final
name String
The name of this child.
final
onPostCall Stream<MessageContext>
A stream that emits contexts after the command callback is executed.
latefinal
onPreCall Stream<MessageContext>
A stream that emits contexts before the command callback is executed.
latefinal
options CommandOptions
The options to use for this entity.
final
parent CommandGroup<CommandContext>?
The parent of this child.
getter/setter pairinherited
resolvedOptions CommandOptions
Get the resolved options for this child.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

check(AbstractCheck check) → void
Add a check to this entity.
inherited
invoke(MessageContext context) Future<void>
Parse arguments, verify checks, call execute and handle call hooks.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited