From ca77b63c97f759bac522da0f146e4a01d0b32cfb Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 26 Jul 2022 23:27:46 -0500 Subject: [PATCH 01/12] Fuck it. This only fixes the crashes on startup, Does NOT work with slash commands. --- commands/help.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/commands/help.js b/commands/help.js index 77e7377..4918e95 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,26 +1,30 @@ +const { Constants } = require('discord.js'); + module.exports = { name: require('path').parse(__filename).name, description: 'Get help on anything from commands, to what the bot does! just not your homework..', options: [{ - name: '', + name: 'command', description: 'View Information about this command', - required: false + required: false, + type: Constants.ApplicationCommandOptionTypes.STRING }], async parseMessage (client, config, message, args) { - await message.channel.send(this.handle(client, config, message.author, args)); + await message.channel.send(this.handle(client, config, message.author, args[0])); }, 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('command'))); }, - handle (client, config, user, args) { - if (!args[0]) { + handle (client, config, user, command) { + if (!command) { return client.generateErrorMessage('Note to self: Design default help embed.', user.displayAvatarURL()); } - const cmdName = args[0].toLowerCase(); + // const cmdName = args[0].toLowerCase(); + const cmdName = command const cmd = client.commands.get(cmdName); if (!cmd) { From b33280a41705d939a64f4bbd3a0a84f42a65fd7c Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Thu, 28 Jul 2022 20:18:06 -0500 Subject: [PATCH 02/12] Change ping locations, bump version number. --- config-example.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/config-example.json b/config-example.json index c5b8a2a..92ac10e 100644 --- a/config-example.json +++ b/config-example.json @@ -3,7 +3,7 @@ "token": "IM SO EXCITED ABOUT BURGER", "ownerID": "MY FAVORITE COLOR IS TWELVE", "release": "Stable Release", - "build": "1.2.2", + "build": "1.3", "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", "sandbox": { "enabled": false, @@ -37,8 +37,15 @@ "127.0.0.1", "Sophie's computer", "Mars", - "Elon Musk", - "TMC Software" + "Netro Corporation", + "System64 Technologies", + "myself", + "Twilight Sparkle", + "the Pokemon Center", + "Who asked?", + "you", + "your mother" + ], "answers": [ "Heck no!", From a0b8b2d5b7d9b1e5a5013e4f9a6d0415b5dadc2d Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Thu, 28 Jul 2022 20:48:52 -0500 Subject: [PATCH 03/12] Remove commands.md as it's no longer needed --- commands.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 commands.md diff --git a/commands.md b/commands.md deleted file mode 100644 index 6d5e7db..0000000 --- a/commands.md +++ /dev/null @@ -1,28 +0,0 @@ -# Anitrox Command List -<> = Optionable -
-[] = Required - -|Command|Arguments |Description | -|-------|----------|------------| -|Help |none |Help? Help!!| -|8ball |[Question]|Ask a question, Any question! | -|avatar |\ |Get a users beautiful avatar | -|bonk |[Member] | Bonk, no horny. | -|cheese |\| Cheese.| -|cuddle |[Member] | Cuddle someone! | -|choose |[Option1]
[Option2]
[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 From 85f2bb252ebccb853730c06df3fda0f3d14cd691 Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Thu, 28 Jul 2022 21:10:39 -0500 Subject: [PATCH 04/12] Fix broken loading spinner on stop/restart commands --- commands/restart.js | 4 ++-- commands/stop.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/restart.js b/commands/restart.js index 992790d..8ef1f9d 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -15,7 +15,7 @@ module.exports = { async handle (client, config, user, channel) { if (user.id === config.ownerID) { const embeds = [{ - title: ' Restart Bot', + title: ' Restart Bot', description: 'Restarting Anitrox...', color: 9442302, footer: { @@ -31,7 +31,7 @@ module.exports = { console.log('[SYSTEM] [INFO] Restarted successfully!'); await response.edit({ embeds: [{ - title: ' Restart Bot', + title: ' Restart Bot', description: 'Restarted!', color: 9442302, footer: { diff --git a/commands/stop.js b/commands/stop.js index 2eb4891..a9c8e0e 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -18,7 +18,7 @@ module.exports = { await channel.send({ embeds: [{ title: '**Shut down the bot**', - description: ' **Shutting Down...**', + description: ' **Shutting Down...**', color: 9442302, footer: { icon_url: user.displayAvatarURL(), From e0685cf7ae95f790dd2932f92f37af68ebd2f6fc Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 2 Aug 2022 21:36:56 -0500 Subject: [PATCH 05/12] Begin support for dotenv --- .env | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..c9cd982 --- /dev/null +++ b/.env @@ -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! From 479792d2dbd42601db543fe1124341352bfb5da3 Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 2 Aug 2022 21:49:52 -0500 Subject: [PATCH 06/12] Move default .env to a .env.example --- config/.env.example | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 config/.env.example diff --git a/config/.env.example b/config/.env.example new file mode 100644 index 0000000..7806214 --- /dev/null +++ b/config/.env.example @@ -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! \ No newline at end of file From 950f00cbd04fbc0471dc5495f37e1be532cd2990 Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 2 Aug 2022 21:50:11 -0500 Subject: [PATCH 07/12] Move configuration files to a seperate directory --- config/config-example.json | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 config/config-example.json diff --git a/config/config-example.json b/config/config-example.json new file mode 100644 index 0000000..92ac10e --- /dev/null +++ b/config/config-example.json @@ -0,0 +1,75 @@ +{ + "prefix": "n!", + "token": "IM SO EXCITED ABOUT BURGER", + "ownerID": "MY FAVORITE COLOR IS TWELVE", + "release": "Stable Release", + "build": "1.3", + "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", + "sandbox": { + "enabled": false, + "id": "793537380330111028", + "refreshLocal": false, + "refreshGlobal": false + }, + + "statuses": [ + "with np!help", + "with Sophie!", + "Trans Rights!", + "in your computer", + "with my internet router", + "ssh: system64@borkeonv2", + "YouTube", + "with source code", + "Visual Studio Code", + "Minecraft", + "with the network connections.", + "VLC Media Player", + "Chromium" + ], + "locations": [ + "Microsoft", + "LinusTechTips", + "Linus Torvalds", + "borkeonv2", + "Google", + "192.168.1.1", + "127.0.0.1", + "Sophie's computer", + "Mars", + "Netro Corporation", + "System64 Technologies", + "myself", + "Twilight Sparkle", + "the Pokemon Center", + "Who asked?", + "you", + "your mother" + + ], + "answers": [ + "Heck no!", + "Are you crazy!? No!", + "Don't even think about it.", + "No! You might bork something!", + "Heck yeah", + "I don't think so.", + "Let me think about it first. No.", + "Let me think about it first. Yeah", + "Let me think about it first. Maybe", + "I don't know man", + "Maybe", + "I'm not sure", + "Ask again", + "YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!", + "Definitely!", + "Go for it! :smile:", + "Good idea!", + "Sure" + ], + "intents": [ + "GUILDS", + "GUILD_MESSAGES", + "GUILD_PRESENCES" + ] +} \ No newline at end of file From 428dc5261e23050504b2262f69418f102f149e5a Mon Sep 17 00:00:00 2001 From: Sophie Marie Date: Tue, 2 Aug 2022 23:25:22 -0500 Subject: [PATCH 08/12] Delete .env --- .env | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index c9cd982..0000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -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! From 0f78055a6694ca609a5dc848c27f2300fb1fdd15 Mon Sep 17 00:00:00 2001 From: Sophie Marie Date: Tue, 2 Aug 2022 23:26:39 -0500 Subject: [PATCH 09/12] git is stupid --- config/.env.example | 3 -- config/config-example.json | 75 -------------------------------------- 2 files changed, 78 deletions(-) delete mode 100644 config/.env.example delete mode 100644 config/config-example.json diff --git a/config/.env.example b/config/.env.example deleted file mode 100644 index 7806214..0000000 --- a/config/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -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! \ No newline at end of file diff --git a/config/config-example.json b/config/config-example.json deleted file mode 100644 index 92ac10e..0000000 --- a/config/config-example.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "prefix": "n!", - "token": "IM SO EXCITED ABOUT BURGER", - "ownerID": "MY FAVORITE COLOR IS TWELVE", - "release": "Stable Release", - "build": "1.3", - "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", - "sandbox": { - "enabled": false, - "id": "793537380330111028", - "refreshLocal": false, - "refreshGlobal": false - }, - - "statuses": [ - "with np!help", - "with Sophie!", - "Trans Rights!", - "in your computer", - "with my internet router", - "ssh: system64@borkeonv2", - "YouTube", - "with source code", - "Visual Studio Code", - "Minecraft", - "with the network connections.", - "VLC Media Player", - "Chromium" - ], - "locations": [ - "Microsoft", - "LinusTechTips", - "Linus Torvalds", - "borkeonv2", - "Google", - "192.168.1.1", - "127.0.0.1", - "Sophie's computer", - "Mars", - "Netro Corporation", - "System64 Technologies", - "myself", - "Twilight Sparkle", - "the Pokemon Center", - "Who asked?", - "you", - "your mother" - - ], - "answers": [ - "Heck no!", - "Are you crazy!? No!", - "Don't even think about it.", - "No! You might bork something!", - "Heck yeah", - "I don't think so.", - "Let me think about it first. No.", - "Let me think about it first. Yeah", - "Let me think about it first. Maybe", - "I don't know man", - "Maybe", - "I'm not sure", - "Ask again", - "YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!", - "Definitely!", - "Go for it! :smile:", - "Good idea!", - "Sure" - ], - "intents": [ - "GUILDS", - "GUILD_MESSAGES", - "GUILD_PRESENCES" - ] -} \ No newline at end of file From cb1eb0a5bdf15db36d6e672338a9eab67abf8a13 Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 2 Aug 2022 23:53:10 -0500 Subject: [PATCH 10/12] Migrate bot-token and ownerid to dotenv --- .env.example | 3 +++ commands/eval.js | 2 +- commands/info.js | 2 +- commands/reload.js | 4 ++-- commands/restart.js | 6 +++--- commands/stop.js | 2 +- config-example.json | 2 -- start.js | 7 +++++-- 8 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..54a5a11 --- /dev/null +++ b/.env.example @@ -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! diff --git a/commands/eval.js b/commands/eval.js index c7a88bc..20b82d5 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -21,7 +21,7 @@ module.exports = { }, handle (client, config, user, code) { - if (user.id === config.ownerID) { + if (user.id === process.env.OWNERID) { try { const evaled = inspect(eval(code)); // await message.channel.send(evaled, { code: 'xl' }); diff --git a/commands/info.js b/commands/info.js index 6906ecb..c87efd7 100644 --- a/commands/info.js +++ b/commands/info.js @@ -32,7 +32,7 @@ module.exports = { { name: '<:anitrox:831193012699791361> Bot Information', value: '** **' }, { name: 'Bot Name', value: `${client.user.tag}`, inline: true }, { name: 'Bot ID', value: `${client.user.id}`, inline: true }, - { name: 'Bot Owner', value: isNaN(config.ownerID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(config.ownerID).username, inline: true }, + { name: 'Bot Owner', value: isNaN(process.env.OWNERID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(process.env.OWNERID).username, inline: true }, { name: 'Release Type', value: config.release, inline: true }, { name: 'Version', value: config.build, inline: true }, { name: ':gear: Bot Process Information', value: '** **' }, diff --git a/commands/reload.js b/commands/reload.js index 5684d5a..9f89ac1 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -5,7 +5,7 @@ module.exports = { name: require('path').parse(__filename).name, description: 'Reloads a command', options: [...Array(10).keys()].map(i => ({ - name: `option${i + 1}`, + name: `option${i + 0}`, description: 'Another option', required: i === 0, type: Constants.ApplicationCommandOptionTypes.STRING @@ -20,7 +20,7 @@ module.exports = { }, 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()); let returnMessage = ''; diff --git a/commands/restart.js b/commands/restart.js index 8ef1f9d..51c91a2 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -13,7 +13,7 @@ module.exports = { }, async handle (client, config, user, channel) { - if (user.id === config.ownerID) { + if (user.id === process.env.OWNERID) { const embeds = [{ title: ' Restart Bot', description: 'Restarting Anitrox...', @@ -27,11 +27,11 @@ module.exports = { const response = await channel.send({ embeds }); try { client.destroy(); - await client.login(config.token); + await client.login(process.env.TOKEN); console.log('[SYSTEM] [INFO] Restarted successfully!'); await response.edit({ embeds: [{ - title: ' Restart Bot', + title: ':white_check_mark: Restart Bot', description: 'Restarted!', color: 9442302, footer: { diff --git a/commands/stop.js b/commands/stop.js index a9c8e0e..9035530 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -13,7 +13,7 @@ module.exports = { }, 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}`); await channel.send({ embeds: [{ diff --git a/config-example.json b/config-example.json index 92ac10e..56e1a1d 100644 --- a/config-example.json +++ b/config-example.json @@ -1,7 +1,5 @@ { "prefix": "n!", - "token": "IM SO EXCITED ABOUT BURGER", - "ownerID": "MY FAVORITE COLOR IS TWELVE", "release": "Stable Release", "build": "1.3", "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", diff --git a/start.js b/start.js index 6d2403b..3c37ded 100755 --- a/start.js +++ b/start.js @@ -3,7 +3,7 @@ const fs = require('fs'); const Discord = require('discord.js'); const config = require('./config.json'); - +require('dotenv').config(); console.log('Starting!'); 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}`); client.commands.set(command.name, command); }); +// Create a collection using those command files fs.readdirSync('./events') .filter(file => file.endsWith('.js')) @@ -21,6 +22,7 @@ fs.readdirSync('./events') .forEach(({ once, event, listener }) => { client[once ? 'once' : 'on'](event, listener(client, config)); }); +// Create listeners from the event files. client.generateErrorMessage = (errorMsg, avatarURL) => ({ embeds: [{ @@ -39,4 +41,5 @@ client.generateErrorMessage = (errorMsg, avatarURL) => ({ }] }); -client.login(config.token); +client.login(process.env.TOKEN); +// Login to Discord! From ca47208da74624252aa5963a4bf3fde442ac9e37 Mon Sep 17 00:00:00 2001 From: IDeletedSystem64 Date: Tue, 2 Aug 2022 23:53:44 -0500 Subject: [PATCH 11/12] Refactor help command! --- commands/help.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/commands/help.js b/commands/help.js index 4918e95..6b98b22 100644 --- a/commands/help.js +++ b/commands/help.js @@ -5,7 +5,7 @@ module.exports = { name: require('path').parse(__filename).name, description: 'Get help on anything from commands, to what the bot does! just not your homework..', options: [{ - name: 'command', + name: 'help', description: 'View Information about this command', required: false, type: Constants.ApplicationCommandOptionTypes.STRING @@ -15,18 +15,30 @@ module.exports = { }, async parseInteraction (client, config, interaction) { - await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('command'))); + await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('help'))); }, handle (client, config, user, command) { if (!command) { - return client.generateErrorMessage('Note to self: Design default help embed.', user.displayAvatarURL()); + return { + embeds: [{ + 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('\n') } + ] + }] + }; } // const cmdName = args[0].toLowerCase(); - const cmdName = command + const cmdName = command; const cmd = client.commands.get(cmdName); - + console.log(cmd.options.map(option => option.required)); if (!cmd) { return client.generateErrorMessage(`${cmdName} is not a valid command! Run ${config.prefix}help for a command list.`); } @@ -43,8 +55,8 @@ module.exports = { { name: 'Command Name', value: `${cmdName}`, inline: true }, { name: 'Command Description', value: cmd.description, inline: true }, { 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: 'Option Legend', value: '[Option] REQUIRED\n