Re-implement auto commands

This commit is contained in:
Dragon Fire
2024-04-06 19:54:49 -04:00
parent 73238a90a2
commit 1681675e46
6 changed files with 61 additions and 18 deletions
+7
View File
@@ -24,6 +24,13 @@ module.exports = class CommandDispatcher {
return Boolean(command);
}
isPatternCommand(msg) {
const patternCommands = this.commands
.filter(cmd => cmd.patterns.length && cmd.patterns.some(pattern => pattern.test(msg.content)));
if (!patternCommands.size) return false;
return patternCommands.first();
}
async parseMessage(msg) {
const matched = msg.content.match(this.commandPattern);
const command = this.resolveCommand(matched[2].toLowerCase());