Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Conversation

@dcarpenter31
Copy link

@dcarpenter31 dcarpenter31 commented Oct 11, 2021

Description

Added a validateCommands() method that is called for each command except for the help command, since its behavior is a little diffrent than the other commands. Also changed the help command a little bit to have a clearer error message when the user enters a command that has not yet been added.

closes #98

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

Comment on lines +22 to +26
if (commands.length > 0) {
// only consider the first command that a user asks for help on to avoid spam
const cmd = this.client.commands.get(commands[0]) || this.client.commands.get(this.client.aliases.get(commands[0]));
if (!cmd) return message.channel.send(`No command named: \`${commands[0]}\` exists`);
embed.setAuthor(`Command Help: ${commands[0]}`, message.guild === null ? null : message.guild.iconURL({ dynamic: true }));
Copy link
Owner

@elenirotsides elenirotsides Oct 11, 2021

Choose a reason for hiding this comment

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

Was Trivia Bot doing something other than Invalid command named: <command name> in response to a nonexistent command? I think your edit here does the same thing as before, but please correct me if I'm wrong! I like the edit on the bot message though, it makes it a little clearer to the user!

Copy link
Author

Choose a reason for hiding this comment

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

yeah, I did not edit the help command much, just changed the parameters to read all of the commands as arguments and edited the message to be a little clearer

Here's the code on main rn for this section:

if (command) {
            const cmd = this.client.commands.get(command) || this.client.commands.get(this.client.aliases.get(command));

            if (!cmd) return message.channel.send(`Invalid Command named: \`${command}\``);

            embed.setAuthor(`Command Help: ${command}`, message.guild === null ? null : message.guild.iconURL({ dynamic: true }));

Copy link
Owner

@elenirotsides elenirotsides left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the awesome PR!

@elenirotsides elenirotsides merged commit 261c578 into elenirotsides:main Oct 12, 2021
@dcarpenter31 dcarpenter31 deleted the exact-match branch October 18, 2021 04:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commands should only be valid when its an exact match

2 participants