Files
SupportBot/commands/ping.js
T

41 lines
1023 B
JavaScript
Raw Normal View History

2020-04-14 22:45:51 +01:00
// TicketDEX, Inspired by SupportBot
// Created by Emerald Services
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
const fs = require("fs");
2019-06-09 23:52:41 +01:00
const Discord = require("discord.js");
2020-04-14 22:45:51 +01:00
const { prefix, token, botname, color } = require("./config.json");
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
const client = new Discord.Client();
client.commands = new Discord.Collection();
2020-01-26 22:35:45 +00:00
2020-04-14 22:45:51 +01:00
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
2020-01-26 22:35:45 +00:00
2020-04-14 22:45:51 +01:00
client.on('ready', () => {
console.log("Bot Connected")
})
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
client.on('message', async message => {
const args = message.content.slice(prefix.length).split(/ +/);
const commandName = args.shift().toLowerCase();
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
if (!client.commands.has(commandName)) return;
2019-06-09 23:52:41 +01:00
2020-04-14 22:45:51 +01:00
const command = client.commands.get(commandName);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Opps! Looks like there was an error trying to execute that command');
}
});
client.login(token)