UserCommand class
Represents a Discord User Command.
UserCommands are commands that can be invoked on a target user from the Discord client.
For example, a simple command that mentions the target user:
test = UserCommand(
'Test',
(UserContext context) {
context.respond(MessageBuilder.content('${context.targetMember?.mention} was the target!'));
},
);
commands.addCommand(test);
You might also be interested in:
- CommandsPlugin.addCommand, for adding commands to your bot;
- ChatCommand, for creating chat commands;
- MessageCommand, for creating message commands.
- Implemented types
Constructors
-
UserCommand(String name, dynamic execute(UserContext), {Iterable<
AbstractCheck> checks = const [], CommandOptions options = const CommandOptions(), Map<Locale, String> ? localizedNames}) - Create a new UserCommand.
Properties
-
checks
→ Iterable<
AbstractCheck> -
The checks that should be applied to this entity.
no setterinherited
- execute → dynamic Function(UserContext)
-
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<
UserContext> -
A stream that emits contexts after the command callback is executed.
latefinal
-
onPreCall
→ Stream<
UserContext> -
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(
UserContext 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