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
23
server.js
23
server.js
|
@ -5,6 +5,7 @@ const {
|
||||||
prefix,
|
prefix,
|
||||||
token,
|
token,
|
||||||
} = require('./config.json');
|
} = require('./config.json');
|
||||||
|
const { basename } = require('path');
|
||||||
|
|
||||||
client.commands = new Discord.Collection();
|
client.commands = new Discord.Collection();
|
||||||
|
|
||||||
|
@ -40,17 +41,23 @@ client.on('message', async message => {
|
||||||
if (!message.content.startsWith(prefix)) return;
|
if (!message.content.startsWith(prefix)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (commandName == "ban" || commandName == "userinfo" || commandName == "botinfo") {
|
|
||||||
command.execute(message, client);
|
switch(commandName){
|
||||||
} else if (commandName == "say" || commandName == "e") {
|
case "ban":
|
||||||
command.execute(message, args)
|
case "userinfo":
|
||||||
}
|
case "botinfo":
|
||||||
else {
|
command.execute(message, client);
|
||||||
command.execute(message);
|
break;
|
||||||
|
case "say":
|
||||||
|
case "e":
|
||||||
|
command.execute(message, args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
command.execute(message)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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