nodbot-rewrite/main.js

48 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-06-14 18:45:04 +00:00
/* eslint-disable no-case-declarations */
/* eslint-disable indent */
// dotenv for handling environment variables
const dotenv = require('dotenv');
dotenv.config();
const token = process.env.TOKEN;;
// Discord.JS
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds
]
});
// Various imports
const fn = require('./modules/functions.js');
const strings = require('./data/strings.json');
2024-06-15 12:22:41 +00:00
const { debugMode, statusChannelId } = require('./data/config.json'); //TODO add debug logic to boot message
2024-06-14 18:45:04 +00:00
client.once('ready', () => {
fn.collectionBuilders.slashCommands(client);
console.log('Ready!');
2024-06-14 19:02:17 +00:00
client.channels.fetch(statusChannelId).then(channel => {
channel.send(`${new Date().toISOString()} -- Ready`).catch(e => console.error(e));
});
2024-06-14 18:45:04 +00:00
});
// slash-commands
client.on('interactionCreate', async interaction => {
if (interaction.isCommand()) {
const { commandName } = interaction;
if (client.slashCommands.has(commandName)) {
client.slashCommands.get(commandName).execute(interaction).catch(e => console.error(e));
} else {
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);
}
}
});
process.on('uncaughtException', err => {
console.error(err);
2024-06-14 19:02:17 +00:00
// TODO: This should probably somehow attempt to send attempt to send a message
2024-06-14 18:45:04 +00:00
});
client.login(token);