abstract away prefix + ev cmd
All checks were successful
Deploy bot / build-and-deploy (push) Successful in 14s
All checks were successful
Deploy bot / build-and-deploy (push) Successful in 14s
This commit is contained in:
10
index.js
10
index.js
@ -20,6 +20,7 @@ const client = new Client({
|
||||
});
|
||||
client.commands = new Collection();
|
||||
client.ownerID = 263247134147608578;
|
||||
client.prefix = prefix;
|
||||
|
||||
fs.readdir("./commands/", (err, files) => {
|
||||
if (err) return console.error(err);
|
||||
@ -73,8 +74,13 @@ client.on(Events.MessageCreate, async (message) => {
|
||||
const cmd = client.commands.get(command);
|
||||
|
||||
if (!cmd) return;
|
||||
|
||||
await cmd.run(client, message, args);
|
||||
try {
|
||||
await cmd.run(client, message, args);
|
||||
} catch (e) {
|
||||
message.channel.send(
|
||||
"Command " + cmd.name + " exited with an exception: " + e
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Log in to Discord with your client's token
|
||||
|
Reference in New Issue
Block a user