Update to 1.3 Stable

nice pr 



Update to Stable 1,3:

    Eval now has access to Client by default. (This is probably a security mess, oh well. lmao)
    Move token and ownerID to .env (Make sure to update your configuration when updating!)
    Refactor the entire help command, It's actually helpful now!:
    Running help now provides a command list, and running help provides information about the command, as it should've originally.
    Refactor info command, It now looks nicer both inside and out.
    Fixed a bug in userinfo where the username in the embed name returned as the User ID
    Other bug fixes.

For developers:

    Added getTime function, This will allow you to get formatted time.
    Moved Uptime to its own

!!!MAKE SURE TO MOVE YOUR TOKEN AND USERID TO THE NEW .ENV!!!
This commit is contained in:
Sophie Marie 2022-08-13 14:00:59 -05:00 committed by GitHub
commit 77acc594b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 160 additions and 197 deletions

3
.env.example Normal file
View file

@ -0,0 +1,3 @@
TOKEN="EVERYTHINGS SO FCKED AND IM TIRED OF BEING SCARED"
OWNERID="SO LETS GET OUT AND FCK UP EQUESTRIA"
# Do !!NOT!! share this file once filled out with anybody, Doing so can leak your Bot Token which will give anyone access to your bot!

3
.gitignore vendored
View file

@ -2,4 +2,5 @@ node_modules/
.vscode .vscode
package-lock.json package-lock.json
releasenotes.txt releasenotes.txt
config.json config.json
.env

View file

@ -3,11 +3,12 @@
This is the stable branch, If you want the prepackaged and prepared builds, you're at the right place. This is the stable branch, If you want the prepackaged and prepared builds, you're at the right place.
# Dependencies to get started # Dependencies to get started
To begin, you will need to satisfy the following dependencies: To begin, you will need to satisfy the following dependencies:
Node.JS: 14 Node.JS: 16
npm: 6.14 npm: 6.14
# Let's get this ~~party~~ bot started! # Let's get this ~~party~~ bot started!
For first time start up, You will need to run ``npm install`` to install the needed npm packages. For first time start up, You will need to run ``npm install`` to install the needed npm packages.
Afterwards fill out the ``config-example.json`` and rename it to ``config.json``, then just run ``node start.js`` (or ``./start.js`` on Linux)! Afterwards fill out the ``.env.example`` and ``config-example.json`` and then rename them to ``.env`` and ``config.json``, then just run ``node start.js`` (or ``./start.js`` on Linux)!
<br>
⚠️ If you don't specify the Owner ID, Some commands such as the bot controls will be unusable! ⚠️ If you don't specify the Owner ID, Some commands such as the bot controls will be unusable!
# Support # Support
Anitrox isn't really supported but you can get help from the Discord server if you need any: discord.gg/5nQtMNpf43 Support is available on the [Discord Server!](discord.gg/5nQtMNpf43), or @ me on [Twitter!](twitter.com/IDeleteSystem64)

View file

@ -1,28 +0,0 @@
# Anitrox Command List
<> = Optionable
<br>
[] = Required
|Command|Arguments |Description |
|-------|----------|------------|
|Help |none |Help? Help!!|
|8ball |[Question]|Ask a question, Any question! |
|avatar |\<Member\> |Get a users beautiful avatar |
|bonk |[Member] | Bonk, no horny. |
|cheese |\<Member\>| Cheese.|
|cuddle |[Member] | Cuddle someone! |
|choose |[Option1] <br> [Option2] <br> [and so on] | Choose from a list of choices, as many as you want!
|hug |[Member] | Hug someone! |
|info |none | Information about the bot and host.
|invite |none | Invite Anitrox to your server!
|kiss |[Member] | Kiss someone! |
|leskiss|[Member] | Lesbain kiss (Suggested by Emi)
|lick |[Member] | Did you just lick me!?
|nom |[Member] | Nom someone or something
|opensource|none | Source code for Anitrox
|pat |[Member] | Pat someone!
|ping |none | Ping Elon Musk! or Mars! nah jk, Discord.
|poke |[Member] | Poke someone!
|slap |[Member] | Slap someone :(
|snuggle|[Member] | Snuggle someone!
|uinfo |[Member] | Information about an user

View file

@ -20,8 +20,8 @@ module.exports = {
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('code'))); await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('code')));
}, },
handle (_, config, user, code) { handle (client, config, user, code) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
try { try {
const evaled = inspect(eval(code)); const evaled = inspect(eval(code));
// await message.channel.send(evaled, { code: 'xl' }); // await message.channel.send(evaled, { code: 'xl' });

View file

@ -1,36 +1,62 @@
const { Constants } = require('discord.js');
module.exports = { module.exports = {
name: require('path').parse(__filename).name, name: require('path').parse(__filename).name,
description: 'Get help on anything from commands, to what the bot does! just not your homework..', description: 'Get help on anything from commands, to what the bot does! just not your homework..',
options: [], options: [{
name: 'help',
async parseMessage (client, config, message) { description: 'The command you want information on',
await message.channel.send(this.handle(client, config, message.author)); required: false,
type: Constants.ApplicationCommandOptionTypes.STRING
}],
async parseMessage (client, config, message, args) {
await message.channel.send(this.handle(client, config, message.author, args[0]));
}, },
async parseInteraction (client, config, interaction) { async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user)); await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('help')));
}, },
handle (_, config, user) { handle (client, config, user, command) {
if (!command) {
return {
embeds: [{
color: 9442302,
title: `:question: SEYMOUR! THE ${client.user.username} IS ON FIRE!`,
description: `Run ${config.prefix}help for more information on each command.`,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
fields: [
{ name: 'Commands', value: client.commands.map(command => command.name).join(', ') }
]
}]
};
}
const cmdName = command;
const cmd = client.commands.get(cmdName);
console.log(cmd.options.map);
if (!cmd) {
return client.generateErrorMessage(`${cmdName} is not a valid command. Run ${config.prefix}help for a command list!`);
}
return { return {
embeds: [{ embeds: [{
title: 'HELP! SEYMOUR! THE BOT IS ON FIRE!',
description: 'Get help on anything from commands, to what the bot does! just not your homework..',
color: 9442302, color: 9442302,
title: ':question: Command Help',
description: `Everything you've ever wanted to know about ${cmdName}!`,
footer: { footer: {
icon_url: user.displayAvatarURL(), icon_url: user.displayAvatarURL(),
text: `${config.footerTxt} | No mother it's just the northern lights` text: config.footerTxt
}, },
fields: [ fields: [
{ { name: 'Command Name', value: `${cmdName}`, inline: true },
name: 'Command List', { name: 'Command Description', value: cmd.description, inline: true },
value: '[Click here!](https://github.com/IDeletedSystem64/anitrox/blob/dev/commands.md)' { name: 'Command Options', value: cmd.options.map(option => option.name).join('\n') || 'None', inline: true },
}, { name: 'Command Option Description', value: cmd.options.map(option => option.description).join('\n') || 'None', inline: true }
{ // { name: 'Command Option Required?', value: cmd.options.map(option => option.required) ? 'Yes' : 'No' }
name: '...Or is the bot actually on fire?',
value: 'Join the [support server!](https://discord.gg/grebRGsBZ3)'
}
] ]
}] }]
}; };

View file

@ -1,117 +1,53 @@
function Uptime (uptime) { const Uptime = require('../functions/uptime.js');
const totalSeconds = (uptime / 1000); const os = require('os');
const osu = require('node-os-utils');
const days = parseInt(totalSeconds / 86400); module.exports = {
const hours = parseInt((totalSeconds % 86400) / 3600); name: 'info',
const minutes = parseInt((totalSeconds % 3600) / 60); description: 'Bot and System information',
const seconds = parseInt(totalSeconds % 60); options: [],
const daystring = days + (days === 1 ? ' day' : ' days'); async parseMessage (client, config, message) {
const hourstring = hours + (hours === 1 ? ' hour' : ' hours'); await message.channel.send(this.handle(client, config, message.author));
const minutestring = minutes + (minutes === 1 ? ' minute' : ' minutes'); },
const secondstring = seconds + (seconds === 1 ? ' second' : ' seconds'); // We'll be moving solely to Slash Commands in 1.4
return `${daystring}**, **${hourstring}**, **${minutestring}**, **${secondstring}`; async parseInteraction (client, config, interaction) {
} await interaction.reply(this.handle(client, config, interaction.user));
},
const os = require('os');
const osu = require('node-os-utils'); handle (client, config, user) {
const cpu = osu.cpu; return {
embeds: [{
module.exports = { title: `<:AnitroxInfo:809651936831733791> Information about ${client.user.username}`,
description: `Everything you've ever wanted to know about your favorite bot, ${client.user.username}!`,
name: require('path').parse(__filename).name, color: 9442302,
description: 'Shows bot and host information', footer: {
options: [], icon_url: user.displayAvatarURL(),
text: config.footerTxt
async parseMessage (client, config, message) { },
await message.channel.send(this.handle(client, config, message.author)); thumbnail: {
}, url: client.user.displayAvatarURL()
},
async parseInteraction (client, config, interaction) { fields: [
await interaction.reply(this.handle(client, config, interaction.user)); { name: '<:anitrox:831193012699791361> Bot Information', value: '** **' },
}, { name: 'Bot Name', value: `${client.user.tag}`, inline: true },
{ name: 'Bot ID', value: `${client.user.id}`, inline: true },
handle (client, config, user) { { name: 'Bot Owner', value: isNaN(process.env.OWNERID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(process.env.OWNERID).username, inline: true },
return { { name: 'Release Type', value: config.release, inline: true },
embeds: [{ { name: 'Version', value: config.build, inline: true },
title: '<:AnitroxInfo:809651936831733791> Information about Anitrox', { name: ':gear: Bot Process Information', value: '** **' },
description: "Everything you've ever wanted to know about your favorite bot, Anitrox!", { name: '<:memory:997565609179107369> Bot Memory Usage', value: `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MiB`, inline: true },
color: 9442302, { name: ':timer: Bot Uptime', value: Uptime(client.uptime), inline: true },
footer: { { name: ':one: Total Servers', value: `** **${client.guilds.cache.size}`, inline: true },
icon_url: user.displayAvatarURL(), { name: '<:hostinfo:997565639352926250> System Information', value: '** **' },
text: config.footerTxt { name: `${((process.platform === 'linux') ? '<:linux_tux:997565742960615424>' : '<:windows:997919047511453696>')} System Platform`, value: process.platform, inline: true },
}, { name: `${((process.platform === 'linux') ? ':gear: Kernel Version' : ':gear: System Version')}`, value: os.release(), inline: true },
thumbnail: { { name: ':timer: System Uptime', value: Uptime(os.uptime() * 1000), inline: true },
url: client.user.displayAvatarURL() { name: '<:cpu:997565592028598282> System CPU Architecture', value: os.arch(), inline: true },
}, { name: '<:cpu:997565592028598282> System CPU Model', value: osu.cpu.model(), inline: true },
fields: [ { name: '<:nodejs:998609124453531740> Node.js Version', value: process.version, inline: true }
{ ]
name: 'Bot Information', }]
value: '** **' };
}, }
{ };
name: 'Release Type',
value: config.release,
inline: true
},
{
name: 'Release Version',
value: config.build,
inline: true
},
{
name: 'Uptime',
value: Uptime(client.uptime),
inline: true
},
{
name: '<:memory:793536677737136178> Bot Memory Usage',
value: `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MiB`,
inline: true
},
{
name: 'Bot Name',
value: client.user.tag,
inline: true
},
{
name: 'Bot ID',
value: `\`${client.user.id}\``,
inline: true
},
{
name: '<:hostinfo:793529505263517747> Host Information',
value: '** **'
},
{
name: '<:hostinfo:793529505263517747> Host Uptime',
value: Uptime(os.uptime() * 1000)
},
{
name: '<:cpu:793672442056802354> CPU Type',
value: `${process.arch}, ${cpu.model()}`
},
{
name: '<:hostos:793866961675223090> OS Type',
value: `${process.platform} / ${os.version()}`
},
{
name: '<:node:793537507018145813> Node.JS Version',
value: process.version
},
{
name: '<:hostinfo:793529505263517747> Bot Ping',
value: `${Math.round(client.ws.ping)} ms`,
inline: true
},
{
name: '**Special Thanks To**',
value: '@OfficialTCGMatt for providing help with development\n @chuu_shi Allowing me to host Anitrox on his server'
}
]
}]
};
}
};

View file

@ -26,18 +26,10 @@ module.exports = {
url: 'https://cdn.discordapp.com/attachments/803658122299572255/814352905394061322/anitroxaddsrvr.png' url: 'https://cdn.discordapp.com/attachments/803658122299572255/814352905394061322/anitroxaddsrvr.png'
}, },
fields: [ fields: [
{ { name: 'Anitrox', value: 'Get the ripe off the vine Anitrox! \n [Add Anitrox to your server](https://discord.com/oauth2/authorize?client_id=576805923964715018&scope=bot&permissions=8)' },
name: 'Anitrox', { name: 'Anitrox PTB (Public Test Build)', value: 'So you want the fresh and hot builds straight from the oven? We gotchu \n [Add Anitrox PTB to your server](https://discord.com/oauth2/authorize?client_id=489125054261755925&scope=bot&permissions=66186303)' },
value: 'Get the ripe off the vine Anitrox! \n [Add Anitrox to your server](https://discord.com/oauth2/authorize?client_id=576805923964715018&scope=bot&permissions=8)' { name: 'Anitrox Dev, Self hosting and more!', value: 'Self-host your own Anitrox (including dev!), Contribute, and more! The possibilites are endless. [Anitrox Source](https://github.com/IDeletedSystem64/anitrox)' },
}, { name: 'Need help?', value: 'Come join the Anitrox Support Server, for support and much more!\n [Anitrox Support Server](https://discord.gg/grebRGsBZ3)' }
{
name: 'Anitrox PTB (Public Test Build)',
value: 'So you want the fresh and hot builds straight from the oven? We gotchu \n [Add Anitrox PTB to your server](https://discord.com/oauth2/authorize?client_id=489125054261755925&scope=bot&permissions=66186303)'
},
{
name: 'Need help?',
value: 'Come join the Anitrox Support Server, for support and much more!\n [Anitrox Support Server](https://discord.gg/grebRGsBZ3)'
}
] ]
}] }]
}; };

View file

@ -5,7 +5,7 @@ module.exports = {
name: require('path').parse(__filename).name, name: require('path').parse(__filename).name,
description: 'Reloads a command', description: 'Reloads a command',
options: [...Array(10).keys()].map(i => ({ options: [...Array(10).keys()].map(i => ({
name: `option${i + 1}`, name: `option${i + 0}`,
description: 'Another option', description: 'Another option',
required: i === 0, required: i === 0,
type: Constants.ApplicationCommandOptionTypes.STRING type: Constants.ApplicationCommandOptionTypes.STRING
@ -20,7 +20,7 @@ module.exports = {
}, },
handle (client, config, user, args) { handle (client, config, user, args) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL()); if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL());
let returnMessage = ''; let returnMessage = '';

View file

@ -13,9 +13,9 @@ module.exports = {
}, },
async handle (client, config, user, channel) { async handle (client, config, user, channel) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
const embeds = [{ const embeds = [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot', title: '<a:AnitroxWorking:997565411212144730> Restart Bot',
description: 'Restarting Anitrox...', description: 'Restarting Anitrox...',
color: 9442302, color: 9442302,
footer: { footer: {
@ -27,11 +27,11 @@ module.exports = {
const response = await channel.send({ embeds }); const response = await channel.send({ embeds });
try { try {
client.destroy(); client.destroy();
await client.login(config.token); await client.login(process.env.TOKEN);
console.log('[SYSTEM] [INFO] Restarted successfully!'); console.log('[SYSTEM] [INFO] Restarted successfully!');
await response.edit({ await response.edit({
embeds: [{ embeds: [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot', title: ':white_check_mark: Restart Bot',
description: 'Restarted!', description: 'Restarted!',
color: 9442302, color: 9442302,
footer: { footer: {

View file

@ -13,12 +13,12 @@ module.exports = {
}, },
async handle (client, config, user, channel) { async handle (client, config, user, channel) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`); console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`);
await channel.send({ await channel.send({
embeds: [{ embeds: [{
title: '**Shut down the bot**', title: '**Shut down the bot**',
description: ':AnitroxWorking: **Shutting Down...**', description: '<a:AnitroxWorking:997565411212144730> **Shutting Down...**',
color: 9442302, color: 9442302,
footer: { footer: {
icon_url: user.displayAvatarURL(), icon_url: user.displayAvatarURL(),

View file

@ -24,7 +24,7 @@ module.exports = {
handle (client, config, user, target) { handle (client, config, user, target) {
return { return {
embeds: [{ embeds: [{
title: `Everything you've ever wanted to know about ${target}!`, title: `Everything you've ever wanted to know about ${target.user.username}!`,
color: 9442302, color: 9442302,
footer: { footer: {
icon_url: user.displayAvatarURL(), icon_url: user.displayAvatarURL(),

View file

@ -1,9 +1,7 @@
{ {
"prefix": "n!", "prefix": "n!",
"token": "IM SO EXCITED ABOUT BURGER",
"ownerID": "MY FAVORITE COLOR IS TWELVE",
"release": "Stable Release", "release": "Stable Release",
"build": "1.2.2", "build": "1.3",
"footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022",
"sandbox": { "sandbox": {
"enabled": false, "enabled": false,
@ -37,8 +35,15 @@
"127.0.0.1", "127.0.0.1",
"Sophie's computer", "Sophie's computer",
"Mars", "Mars",
"Elon Musk", "Netro Corporation",
"TMC Software" "System64 Technologies",
"myself",
"Twilight Sparkle",
"the Pokemon Center",
"Who asked?",
"you",
"your mother"
], ],
"answers": [ "answers": [
"Heck no!", "Heck no!",

View file

@ -1 +0,0 @@

View file

@ -46,6 +46,7 @@ module.exports = {
console.log(' / /| | / __ \\/ / __/ ___/ __ \\| |/_/'); console.log(' / /| | / __ \\/ / __/ ___/ __ \\| |/_/');
console.log(' / ___ |/ / / / / /_/ / / /_/ /> < '); console.log(' / ___ |/ / / / / /_/ / / /_/ /> < ');
console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| '); console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| ');
console.log('');
console.log(`${config.release}, ${config.build}`); console.log(`${config.release}, ${config.build}`);
console.log('Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!'); console.log('Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!');
// Statuses // Statuses

7
functions/getTime.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = () => {
const date = new Date();
const timeDate = date.toLocaleDateString();
const time = date.toLocaleTimeString();
return ` ${time} | ${timeDate} `;
};

15
functions/uptime.js Normal file
View file

@ -0,0 +1,15 @@
module.exports = (uptime) => {
const tSeconds = (uptime / 1000);
const tDays = parseInt(tSeconds / 86400);
const tHrs = parseInt((tSeconds % 86400) / 3600);
const tMins = parseInt((tSeconds % 3600) / 60);
const tSecs = parseInt(tSeconds % 60);
const days = tDays + (tDays === 1 ? ' day' : ' days');
const hours = tHrs + (tHrs === 1 ? ' hour' : ' hours');
const minutes = tMins + (tMins === 1 ? ' minute' : ' minutes');
const seconds = tSecs + (tSecs === 1 ? ' second' : ' seconds');
return `${days}, ${hours}, ${minutes}, ${seconds}`;
};

View file

@ -5,6 +5,8 @@
"main": "start.js", "main": "start.js",
"dependencies": { "dependencies": {
"discord.js": "^13.6.0", "discord.js": "^13.6.0",
"dotenv": "^16.0.1",
"node-fetch": "^3.2.9",
"node-os-utils": "^1.3.2", "node-os-utils": "^1.3.2",
"require-all": "^3.0.0" "require-all": "^3.0.0"
}, },

View file

@ -3,7 +3,7 @@
const fs = require('fs'); const fs = require('fs');
const Discord = require('discord.js'); const Discord = require('discord.js');
const config = require('./config.json'); const config = require('./config.json');
require('dotenv').config();
console.log('Starting!'); console.log('Starting!');
const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) }); const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) });
@ -14,6 +14,7 @@ fs.readdirSync('./commands')
const command = require(`./commands/${file}`); const command = require(`./commands/${file}`);
client.commands.set(command.name, command); client.commands.set(command.name, command);
}); });
// Create a collection using those command files
fs.readdirSync('./events') fs.readdirSync('./events')
.filter(file => file.endsWith('.js')) .filter(file => file.endsWith('.js'))
@ -21,6 +22,7 @@ fs.readdirSync('./events')
.forEach(({ once, event, listener }) => { .forEach(({ once, event, listener }) => {
client[once ? 'once' : 'on'](event, listener(client, config)); client[once ? 'once' : 'on'](event, listener(client, config));
}); });
// Create listeners from the event files.
client.generateErrorMessage = (errorMsg, avatarURL) => ({ client.generateErrorMessage = (errorMsg, avatarURL) => ({
embeds: [{ embeds: [{
@ -39,4 +41,5 @@ client.generateErrorMessage = (errorMsg, avatarURL) => ({
}] }]
}); });
client.login(config.token); client.login(process.env.TOKEN);
// Login to Discord!