Do not respond to command without prefix. Allow matching

[ci skip]
This commit is contained in:
Szymon Uglis 2020-06-07 13:49:20 +02:00
parent f4c2d61ee8
commit b03b73b685
2 changed files with 6 additions and 2 deletions

View file

@ -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;
}

View file

@ -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;
}
}