Changed if/else block to switch case instead for better readability
This commit is contained in:
parent
421b1272ed
commit
268ef88332
1 changed files with 15 additions and 8 deletions
21
server.js
21
server.js
|
@ -5,6 +5,7 @@ const {
|
|||
prefix,
|
||||
token,
|
||||
} = require('./config.json');
|
||||
const { basename } = require('path');
|
||||
|
||||
client.commands = new Discord.Collection();
|
||||
|
||||
|
@ -40,17 +41,23 @@ client.on('message', async message => {
|
|||
if (!message.content.startsWith(prefix)) return;
|
||||
|
||||
try {
|
||||
if (commandName == "ban" || commandName == "userinfo" || commandName == "botinfo") {
|
||||
|
||||
switch(commandName){
|
||||
case "ban":
|
||||
case "userinfo":
|
||||
case "botinfo":
|
||||
command.execute(message, client);
|
||||
} else if (commandName == "say" || commandName == "e") {
|
||||
command.execute(message, args)
|
||||
}
|
||||
else {
|
||||
command.execute(message);
|
||||
break;
|
||||
case "say":
|
||||
case "e":
|
||||
command.execute(message, args);
|
||||
break;
|
||||
default:
|
||||
command.execute(message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('There was an error trying to execute that command!');
|
||||
message.channel.send('There was an error trying to execute that command!');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue