Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/command-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export class CommandHandler {

// returns false if the message was not a wheatley command
private async handle_text_command(message: Discord.Message, prev_command_obj?: TextBasedCommand) {
const match = message.content.match(CommandHandler.command_regex);
const cmd = message.content.replace(new RegExp(String.raw`^\s*<@${this.wheatley.client.user?.id}>\s*`), "");
const match = cmd.match(CommandHandler.command_regex);
if (!match) {
// starts with ! but doesn't match the command regex
return false;
Expand All @@ -143,7 +144,7 @@ export class CommandHandler {

return false;
}
let command_body = message.content.substring(match[0].length).trim();
let command_body = cmd.substring(match[0].length).trim();
let command = this.text_commands[command_name];
const command_obj = prev_command_obj
? new TextBasedCommand(prev_command_obj, command_name, command, message)
Expand Down Expand Up @@ -292,7 +293,8 @@ export class CommandHandler {
if (message.guildId !== this.wheatley.guild.id) {
return;
}
if (message.content.startsWith("!")) {
const cmd = message.content.replace(new RegExp(String.raw`^\s*<@${this.wheatley.client.user?.id}>\s*`), "");
if (cmd.startsWith("!")) {
await this.handle_text_command(message);
}
} catch (e) {
Expand Down