Do not respond to command without prefix. Allow matching
[ci skip]
This commit is contained in:
parent
f4c2d61ee8
commit
b03b73b685
|
@ -71,11 +71,15 @@ class Commander {
|
|||
return;
|
||||
}
|
||||
|
||||
if(!event.message.content.startsWith(prefix)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: NNBD: try-catch in where
|
||||
CommandHandler? matchingCommand;
|
||||
try {
|
||||
matchingCommand = _commands.firstWhere(
|
||||
(element) => _isCommandMatching(element.commandName, event.message.content.replaceFirst(prefix, "")));
|
||||
(element) => _isCommandMatching(element.commandName, event.message.content.replaceFirst(prefix, "").trim()));
|
||||
} on Error {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ bool _isCommandMatching(String command, String message) {
|
|||
}
|
||||
|
||||
for (var i = 0; i < commandParts.length; i++) {
|
||||
if (commandParts[i] != messageParts[i]) {
|
||||
if (commandParts[i].trim() != messageParts[i].trim()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue