mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 15:57:50 +02:00
Re-implement auto commands
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user