2021-09-22 17:15:31 +00:00
|
|
|
/* eslint-disable no-case-declarations */
|
|
|
|
/* eslint-disable indent */
|
|
|
|
// dotenv for handling environment variables
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
dotenv.config();
|
2023-02-14 06:22:15 +00:00
|
|
|
const token = process.env.TOKEN;;
|
2021-09-22 17:15:31 +00:00
|
|
|
|
|
|
|
// Discord.JS
|
2023-02-14 06:22:15 +00:00
|
|
|
const { Client, GatewayIntentBits } = require('discord.js');
|
2021-09-22 17:15:31 +00:00
|
|
|
const client = new Client({
|
|
|
|
intents: [
|
2023-02-14 06:22:15 +00:00
|
|
|
GatewayIntentBits.Guilds
|
|
|
|
]
|
2021-09-22 17:15:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Various imports
|
2023-02-14 06:22:15 +00:00
|
|
|
const fn = require('./modules/functions.js');
|
|
|
|
const strings = require('./data/strings.json');
|
|
|
|
const debugMode = process.env.DEBUG;
|
|
|
|
const statusChannelId = process.env.STATUSCHANNELID
|
2021-09-22 17:15:31 +00:00
|
|
|
|
|
|
|
client.once('ready', () => {
|
2023-02-14 06:22:15 +00:00
|
|
|
fn.collectionBuilders.slashCommands(client);
|
2021-09-22 17:15:31 +00:00
|
|
|
console.log('Ready!');
|
2023-02-14 06:22:15 +00:00
|
|
|
// client.channels.fetch(statusChannelId).then(channel => {
|
|
|
|
// channel.send(`${new Date().toISOString()} -- Ready`).catch(e => console.error(e));
|
|
|
|
// });
|
2021-09-22 17:15:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// slash-commands
|
|
|
|
client.on('interactionCreate', async interaction => {
|
|
|
|
if (interaction.isCommand()) {
|
|
|
|
const { commandName } = interaction;
|
|
|
|
|
|
|
|
if (client.slashCommands.has(commandName)) {
|
2023-02-14 06:22:15 +00:00
|
|
|
client.slashCommands.get(commandName).execute(interaction).catch(e => console.error(e));
|
2021-09-22 17:15:31 +00:00
|
|
|
} else {
|
2023-02-14 06:22:15 +00:00
|
|
|
interaction.reply('Sorry, I don\'t have access to that command.').catch(e => console.error(e));
|
|
|
|
console.error('Slash command attempted to run but not found: /' + commandName);
|
2023-01-08 01:00:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-22 17:15:31 +00:00
|
|
|
});
|
|
|
|
|
2023-02-14 06:22:15 +00:00
|
|
|
process.on('uncaughtException', err => {
|
|
|
|
console.error(err);
|
2021-09-22 17:15:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
client.login(token);
|