2022-03-26 03:33:18 -05:00
|
|
|
#!/usr/bin/env -S node
|
|
|
|
|
2021-02-11 21:39:01 -06:00
|
|
|
const fs = require('fs');
|
|
|
|
const Discord = require('discord.js');
|
2022-03-28 10:56:21 -05:00
|
|
|
const config = require('./config.json');
|
2022-08-02 23:53:10 -05:00
|
|
|
require('dotenv').config();
|
2022-04-21 18:09:21 -05:00
|
|
|
console.log('Starting!');
|
|
|
|
const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) });
|
2021-02-11 21:39:01 -06:00
|
|
|
|
2022-04-21 20:53:03 -05:00
|
|
|
client.commands = new Discord.Collection();
|
2022-05-14 03:57:05 -05:00
|
|
|
fs.readdirSync('./commands')
|
|
|
|
.filter(file => file.endsWith('.js'))
|
|
|
|
.forEach(file => {
|
|
|
|
const command = require(`./commands/${file}`);
|
|
|
|
client.commands.set(command.name, command);
|
|
|
|
});
|
2022-08-02 23:53:10 -05:00
|
|
|
// Create a collection using those command files
|
2022-05-14 03:57:05 -05:00
|
|
|
|
|
|
|
fs.readdirSync('./events')
|
|
|
|
.filter(file => file.endsWith('.js'))
|
|
|
|
.map(file => require(`./events/${file}`))
|
|
|
|
.forEach(({ once, event, listener }) => {
|
|
|
|
client[once ? 'once' : 'on'](event, listener(client, config));
|
|
|
|
});
|
2022-08-02 23:53:10 -05:00
|
|
|
// Create listeners from the event files.
|
2021-02-11 21:39:01 -06:00
|
|
|
|
2022-04-21 18:09:21 -05:00
|
|
|
client.generateErrorMessage = (errorMsg, avatarURL) => ({
|
|
|
|
embeds: [{
|
|
|
|
title: '<:AnitroxError:809651936563429416> Error',
|
|
|
|
color: 13632027,
|
|
|
|
footer: {
|
|
|
|
icon_url: avatarURL,
|
|
|
|
text: config.footerTxt
|
|
|
|
},
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: 'Something went wrong!',
|
|
|
|
value: errorMsg
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
});
|
2022-03-26 12:31:03 -05:00
|
|
|
|
2022-08-02 23:53:10 -05:00
|
|
|
client.login(process.env.TOKEN);
|
|
|
|
// Login to Discord!
|