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');
|
2022-12-06 20:42:00 -06:00
|
|
|
const { Client, Collection, GatewayIntentBits } = 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!');
|
2022-12-06 20:42:00 -06:00
|
|
|
// const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) });
|
|
|
|
const client = new Client({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.GuildPresences
|
|
|
|
]
|
|
|
|
});
|
|
|
|
// todo: move back to file
|
|
|
|
client.commands = new 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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
});
|
2023-01-25 16:10:45 -06:00
|
|
|
// Error message generator.
|
|
|
|
|
|
|
|
client.updater = require('./functions/updateCheck.js')(); // da update checker (real)
|
2022-03-26 12:31:03 -05:00
|
|
|
|
2022-08-02 23:53:10 -05:00
|
|
|
client.login(process.env.TOKEN);
|
|
|
|
// Login to Discord!
|