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 { statuses, build, release, prefix, token, footerTxt } = require('./config.json');
|
|
|
|
const config = require('./config.json');
|
2022-03-17 21:55:08 -05:00
|
|
|
console.log('Starting!')
|
2021-02-11 21:39:01 -06:00
|
|
|
const client = new Discord.Client();
|
|
|
|
client.commands = new Discord.Collection();
|
|
|
|
|
|
|
|
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
|
|
|
const command = require(`./commands/${file}`);
|
|
|
|
client.commands.set(command.name, command);
|
|
|
|
}
|
|
|
|
|
2022-03-26 12:31:03 -05:00
|
|
|
client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embed: {
|
|
|
|
"title": "<:AnitroxError:809651936563429416> Error",
|
|
|
|
"color": 13632027,
|
|
|
|
"footer": {
|
|
|
|
"icon_url": messageAuthorURL,
|
|
|
|
"text": footerTxt
|
|
|
|
},
|
|
|
|
"fields": [
|
|
|
|
{
|
2022-03-28 10:56:21 -05:00
|
|
|
"name": "Something went wrong!",
|
2022-03-26 12:31:03 -05:00
|
|
|
"value": errorMsg
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}})
|
|
|
|
|
2022-03-26 13:20:32 -05:00
|
|
|
client.on("error", (e) => console.log(`[ERROR] ${error(e)}`));
|
|
|
|
client.on("warn", (e) => (`[WARN] ${warn(e)}`));
|
2021-02-11 21:39:01 -06:00
|
|
|
client.once('ready', () => {
|
|
|
|
console.clear()
|
|
|
|
console.log(' ___ _ __ ');
|
|
|
|
console.log(' / | ____ (_) /__________ _ __');
|
2022-03-26 13:20:32 -05:00
|
|
|
console.log(' / /| | / __ \\/ / __/ ___/ __ \\| |/_/');
|
2021-02-11 21:39:01 -06:00
|
|
|
console.log(' / ___ |/ / / / / /_/ / / /_/ /> < ');
|
2022-03-26 13:20:32 -05:00
|
|
|
console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| ');
|
2022-03-28 10:56:21 -05:00
|
|
|
console.log(`${config.release}, ${config.build}`);
|
|
|
|
console.log("Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!");
|
2021-02-11 21:39:01 -06:00
|
|
|
});
|
2022-03-17 21:47:23 -05:00
|
|
|
|
2022-03-26 03:33:18 -05:00
|
|
|
|
2022-03-26 11:02:17 -05:00
|
|
|
setInterval(async () => {
|
2022-03-26 03:33:18 -05:00
|
|
|
// Picks a status from the config file
|
2022-03-28 10:56:21 -05:00
|
|
|
const index = Math.floor(Math.random() * config.statuses.length);
|
2022-03-26 11:02:17 -05:00
|
|
|
await client.user.setActivity(statuses[index]);
|
2021-02-11 21:39:01 -06:00
|
|
|
}, 20000);
|
2022-03-18 11:04:08 -05:00
|
|
|
|
|
|
|
// Begin Command Handler
|
2022-03-26 03:33:18 -05:00
|
|
|
client.on('message', async (message) => {
|
2021-02-11 21:39:01 -06:00
|
|
|
|
2022-03-18 11:04:08 -05:00
|
|
|
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
2022-03-26 03:33:18 -05:00
|
|
|
|
2021-02-11 21:39:01 -06:00
|
|
|
const args = message.content.slice(prefix.length).split(/ +/);
|
|
|
|
const command = args.shift().toLowerCase();
|
|
|
|
|
|
|
|
if (!client.commands.has(command)) return;
|
|
|
|
|
|
|
|
try {
|
2022-03-28 10:56:21 -05:00
|
|
|
await client.commands.get(command).execute(client, message, args, config);
|
2021-02-11 21:39:01 -06:00
|
|
|
} catch (error) {
|
2022-03-26 03:33:18 -05:00
|
|
|
console.stack;
|
2022-03-26 12:31:03 -05:00
|
|
|
message.channel.send({embed: {
|
2022-03-17 21:47:23 -05:00
|
|
|
"title": "<:AnitroxError:809651936563429416> **Something went wrong!**",
|
|
|
|
"description": error.stack,
|
2021-02-11 21:39:01 -06:00
|
|
|
"color": 13632027,
|
2022-03-26 12:31:03 -05:00
|
|
|
"footer": {
|
|
|
|
"icon_url": message.author.displayAvatarURL(),
|
2022-03-28 10:56:21 -05:00
|
|
|
"text": config.footerTxt
|
2022-03-26 12:31:03 -05:00
|
|
|
},
|
|
|
|
}});
|
2021-02-11 21:39:01 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-28 10:56:21 -05:00
|
|
|
client.login(config.token);
|