Skip to content
Merged
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
18 changes: 17 additions & 1 deletion src/command-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}

// returns false if the message was not a wheatley command
private async handle_text_command(message: Discord.Message, prev_command_obj?: TextBasedCommand) {

Check failure on line 128 in src/command-handler.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=TCCPP_wheatley&issues=AZ99zQMvNHU3YT6pwLjq&open=AZ99zQMvNHU3YT6pwLjq&pullRequest=214
const match = message.content.match(CommandHandler.command_regex);
if (!match) {
// starts with ! but doesn't match the command regex
Expand All @@ -134,6 +134,13 @@
const command_name = match[1];
if (!(command_name in this.text_commands)) {
// unknown command

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment, special case below in diff


if (this.wheatley.devmode_enabled) {
await message.reply({
content: `Unknown text command: ${command_name}`,
});
}

return false;
}
let command_body = message.content.substring(match[0].length).trim();
Expand Down Expand Up @@ -186,7 +193,16 @@

private async handle_slash_comand(interaction: Discord.ChatInputCommandInteraction) {
if (!(interaction.commandName in this.text_commands)) {
// TODO: Unknown command
// unknown command

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment, TODO is done.


if (this.wheatley.devmode_enabled) {
await interaction.reply({
content: `Unknown slash command: ${interaction.commandName}`,
flags: Discord.MessageFlags.Ephemeral,
});
}

return;
}
let command = this.text_commands[interaction.commandName];
let command_log_name = interaction.commandName;
Expand Down
Loading