This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
anitrox/start.js

87 lines
2.9 KiB
JavaScript
Raw Normal View History

2021-08-27 16:15:26 -05:00
console.log("Let's get started")
const fs = require('fs');
const Discord = require('discord.js');
2021-08-27 16:15:26 -05:00
const { MessageActionRow, MessageButton } = require('discord.js')
2022-01-12 13:13:23 -06:00
const { build, release, prefix, token, footer } = require('./config.json');
const os = require("os");
const activities_list = [
"with np!help",
2021-07-21 15:48:17 -05:00
"with Sophie!",
"Trans Rights!",
"in your computer",
"with my internet router",
"ssh: system64@borkeonv2",
"YouTube",
"with source code",
2021-08-27 16:15:26 -05:00
"Visual Studio Code",
"Running Anitrox" + build
];
console.log('Starting! This should only take a moment.')
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);
}
client.on("error", (e) => console.log("[ERROR]" + error(e)));
client.on("warn", (e) => ("[WARN]" + warn(e)));
// Log errors and warnings ton console.
client.once('ready', () => {
console.clear()
console.log(' ___ _ __ ');
console.log(' / | ____ (_) /__________ _ __');
console.log(' / /| | / __ \/ / __/ ___/ __ \| |/_/');
console.log(' / ___ |/ / / / / /_/ / / /_/ /> < ');
console.log('/_/ |_/_/ /_/_/\__/_/ \____/_/|_| ')
2021-06-08 21:25:37 -05:00
console.log(release + ", " + build)
console.log("All Systems Go. | Anitrox by IDeletedSystem64 | meow meow :3");
});
2021-08-27 16:15:26 -05:00
// does a cool logo thingy on start up
setInterval(() => {
const index = Math.floor(Math.random() * (activities_list.length - 1) + 1);
client.user.setActivity(activities_list[index]);
}, 20000);
2021-08-27 16:15:26 -05:00
// runs some math to randomly pick a status from activites_list, this may need tuning when statuses are added/removed to make it more random (as it may just land on the current status instead)
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(client, message, args, Discord, footer);
} catch (error) {
2021-06-08 21:25:37 -05:00
console.stack
const embed = {
"title": "<:AnitroxError:809651936563429416> **Well that happened...**",
"color": 13632027,
"footer": {
"icon_url": "https://cdn.discordapp.com/attachments/549707869138714635/793524910172667964/Screenshot_26.png",
2021-06-08 21:25:37 -05:00
"text": footer
},
"fields": [
{
"name": "**What Happened?**",
"value": "The command you tried to run failed to execute due to an error."
},
{
"name": "Error Info",
"value": error.stack
}
]
};
message.channel.send({ embed });
2021-08-27 16:15:26 -05:00
// tries to run the executed command, if fails it will send a error msg with the error stack
}
});
client.login(token);