From 2189417343b0c79d82cacf2652d90cbabd7fa0e2 Mon Sep 17 00:00:00 2001 From: Nathaniel Mason Date: Thu, 21 Apr 2022 17:29:04 +0100 Subject: [PATCH] Quick and dirty update to discord.js v13 --- commands/8ball.js | 4 ++-- commands/avatar.js | 4 ++-- commands/bonk.js | 4 ++-- commands/cheese.js | 4 ++-- commands/choose.js | 4 ++-- commands/cuddle.js | 4 ++-- commands/eval.js | 4 ++-- commands/help.js | 4 ++-- commands/hug.js | 4 ++-- commands/info.js | 4 ++-- commands/invite.js | 4 ++-- commands/kiss.js | 4 ++-- commands/leskiss.js | 4 ++-- commands/lick.js | 4 ++-- commands/nom.js | 4 ++-- commands/opensource.js | 4 ++-- commands/pat.js | 4 ++-- commands/ping.js | 4 ++-- commands/poke.js | 4 ++-- commands/reload.js | 4 ++-- commands/setnick.js | 4 ++-- commands/slap.js | 4 ++-- commands/snuggle.js | 4 ++-- commands/stop.js | 8 ++++---- commands/uinfo.js | 4 ++-- config-example.json | 4 ++++ package.json | 2 +- start.js | 12 ++++++------ 28 files changed, 63 insertions(+), 59 deletions(-) diff --git a/commands/8ball.js b/commands/8ball.js index 2748458..927f6d9 100644 --- a/commands/8ball.js +++ b/commands/8ball.js @@ -12,7 +12,7 @@ module.exports = { if (!question) { await message.channel.send(client.generateErrorMessage("You need to ask a question!", message.author.displayAvatarURL)); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":8ball: 8Ball", "description": `Your amazing question: **${question}**`, "color": 9442302, @@ -26,7 +26,7 @@ module.exports = { "value": `${answer}` } ] - }}); + }]}); } } } \ No newline at end of file diff --git a/commands/avatar.js b/commands/avatar.js index 615ce63..2cf250b 100644 --- a/commands/avatar.js +++ b/commands/avatar.js @@ -6,7 +6,7 @@ module.exports = { async execute(client, message, args, config) { const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": `:frame_photo: ${user.username}'s Beautiful Avatar!`, "color": 9442302, "footer": { @@ -16,6 +16,6 @@ module.exports = { "image": { "url": user.displayAvatarURL() } - }}); + }]}); } } diff --git a/commands/bonk.js b/commands/bonk.js index 87dc359..7c4d6ca 100644 --- a/commands/bonk.js +++ b/commands/bonk.js @@ -9,7 +9,7 @@ module.exports = { if(!taggedUser) { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": " Bonk", "description": `${taggedUser} You have been bonked by ${message.author}!`, "color": 9442302, @@ -20,7 +20,7 @@ module.exports = { "image": { "url": "https://cdn.discordapp.com/attachments/793537380330111028/801194481549312060/HappyBONK.gif" } - }}); + }]}); } } } diff --git a/commands/cheese.js b/commands/cheese.js index c3b2f59..d735d41 100644 --- a/commands/cheese.js +++ b/commands/cheese.js @@ -9,7 +9,7 @@ module.exports = { if(!taggedUser) { await message.channel.send("*slams cheese on desk*\n**Cheese.** https://www.youtube.com/watch?v=Or4IE8fkpn4"); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":cheese: Cheesed", "description": `${taggedUser} You have been cheesed by ${message.author}!`, "color": 16312092, @@ -20,7 +20,7 @@ module.exports = { "image": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/812867714368536636/R06325af354168febcafd96b8328b7590.png" } - }}); + }]}); } } } diff --git a/commands/choose.js b/commands/choose.js index 99e3aaf..38d4f37 100644 --- a/commands/choose.js +++ b/commands/choose.js @@ -12,7 +12,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL())); } else { const answer = options[Math.floor(Math.random() * options.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "I have made my decision:", "description": answer, "color": 8311585, @@ -20,7 +20,7 @@ module.exports = { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt }, - }}); + }]}); } } } diff --git a/commands/cuddle.js b/commands/cuddle.js index 5825a73..a6c82d3 100644 --- a/commands/cuddle.js +++ b/commands/cuddle.js @@ -18,7 +18,7 @@ module.exports = { if(!taggedUser) { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":heart: Cuddle", "description": `${taggedUser} You have been cuddled by ${message.author}!`, "color": 9442302, @@ -29,7 +29,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/eval.js b/commands/eval.js index 86b0f18..9edab67 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -12,7 +12,7 @@ module.exports = { const evaled = inspect(eval(code)); await message.channel.send(evaled, {code:"xl"}); } catch (error) { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:AnitroxError:809651936563429416> **Something went wrong! **", "color": 13632027, "footer": { @@ -29,7 +29,7 @@ module.exports = { "value": error.message } ] - }}); + }]}); } }; } diff --git a/commands/help.js b/commands/help.js index e2bd143..3d312f9 100644 --- a/commands/help.js +++ b/commands/help.js @@ -5,7 +5,7 @@ module.exports = { syntax: '', async execute(_0, message, _1, config) { - await message.channel.send({embed: { + await message.channel.send({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, @@ -23,6 +23,6 @@ module.exports = { "value": "Join the [support server!](https://discord.gg/grebRGsBZ3)" } ] - }}); + }]}); } } diff --git a/commands/hug.js b/commands/hug.js index c294752..ed29754 100644 --- a/commands/hug.js +++ b/commands/hug.js @@ -18,7 +18,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": " Hug", "description": `${taggedUser} You have been hugged by ${message.author}!`, "color": 8311585, @@ -29,7 +29,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/info.js b/commands/info.js index 41ce529..4c4f5b2 100644 --- a/commands/info.js +++ b/commands/info.js @@ -24,7 +24,7 @@ module.exports = { const osu = require('node-os-utils'); const cpu = osu.cpu; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:AnitroxInfo:809651936831733791> Information about Anitrox", "description": "Everything you've ever wanted to know about your favorite bot, Anitrox!", "color": 9442302, @@ -102,6 +102,6 @@ module.exports = { } ] - }}); + }]}); } }; diff --git a/commands/invite.js b/commands/invite.js index a17a2c8..94e26ad 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -5,7 +5,7 @@ module.exports = { syntax: [], async execute(_0, message, _1, config) { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "Add Anitrox to your Server!", "description": "Weather you want stable, or that squeaky clean fresh PTB build, we gotchu.", "color": 9442302, @@ -30,6 +30,6 @@ module.exports = { "value": "Come join the Anitrox Support Server, for support and much more!\n [Anitrox Support Server](https://discord.gg/grebRGsBZ3)" } ] - }}); + }]}); }, }; \ No newline at end of file diff --git a/commands/kiss.js b/commands/kiss.js index 921deb8..a7ac11a 100644 --- a/commands/kiss.js +++ b/commands/kiss.js @@ -18,7 +18,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":heart: Kiss", "description": `${taggedUser} You have been kissed by ${message.author}!`, "color": 9442302, @@ -29,7 +29,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/leskiss.js b/commands/leskiss.js index 85b3d79..77472b9 100644 --- a/commands/leskiss.js +++ b/commands/leskiss.js @@ -28,7 +28,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":heart: <:lesbian:803831629428686849> Kiss", "description": `${taggedUser} You have been kissed by ${message.author}!`, "color": 8311585, @@ -39,7 +39,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/lick.js b/commands/lick.js index 92e3ec8..903ea0d 100644 --- a/commands/lick.js +++ b/commands/lick.js @@ -17,7 +17,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": " Lick", "description": `${taggedUser} You have been licked by ${message.author}!`, "color": 8311585, @@ -28,7 +28,7 @@ module.exports = { "image": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/805314244123951114/cef569820773b0f5d54ee34cfa18e1f8.gif" } - }}); + }]}); } } } diff --git a/commands/nom.js b/commands/nom.js index 314dce4..955a85f 100644 --- a/commands/nom.js +++ b/commands/nom.js @@ -17,7 +17,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:BlobNomBlob:801241117919805510> Nom", "description": `${taggedUser} You have been nommed by ${message.author}!`, "color": 8311585, @@ -28,7 +28,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/opensource.js b/commands/opensource.js index 3b9dc16..05d5b4c 100644 --- a/commands/opensource.js +++ b/commands/opensource.js @@ -4,7 +4,7 @@ module.exports = { description: 'Attributions to open source components used by Anitrox', async execute(_0, message, _1, config){ - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "Component Attribution", "description": "Some parts of Anitrox are using open source code, and their attributions are avaliable here!", "color": 52508, @@ -29,6 +29,6 @@ module.exports = { "value": "Using and supporting the Anitrox Project, thank you! ❤" } ] - }}); + }]}); } } \ No newline at end of file diff --git a/commands/pat.js b/commands/pat.js index 27a7db1..454c987 100644 --- a/commands/pat.js +++ b/commands/pat.js @@ -16,7 +16,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:pats:801238281286713355> Pat", "description": `${taggedUser} You have been patted by ${message.author}!`, "color": 8311585, @@ -27,7 +27,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/ping.js b/commands/ping.js index df10b93..0815271 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -7,7 +7,7 @@ module.exports = { const index = Math.floor(Math.random() * config.locations.length); const location = config.locations[index] - await message.channel.send({embed:{ + await message.channel.send({embeds:[{ "title": ":ping_pong: Ping", "description": `**Pong!** We pinged **${location}** and got ${client.ws.ping} ms.`, "color": 9442302, @@ -15,6 +15,6 @@ module.exports = { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt } - }}); + }]}); } }; diff --git a/commands/poke.js b/commands/poke.js index 346ab47..ea98dd9 100644 --- a/commands/poke.js +++ b/commands/poke.js @@ -16,7 +16,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "👉 Poke!", "description": `${taggedUser} You have been poked by ${message.author}!`, "color": 8311585, @@ -27,7 +27,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } diff --git a/commands/reload.js b/commands/reload.js index 05f048d..95ec266 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -31,7 +31,7 @@ module.exports = { }); } else { - message.channel.send({embed: { + message.channel.send({embeds: [{ "title": "<:AnitroxDenied:809651936642203668> **403 Forbidden**", "color": 13632027, "footer": { @@ -44,7 +44,7 @@ module.exports = { "value": "You don't have the appropriate permissions to run this command!" } ] - }}); + }]}); } } }; \ No newline at end of file diff --git a/commands/setnick.js b/commands/setnick.js index a097ed1..30de3e1 100644 --- a/commands/setnick.js +++ b/commands/setnick.js @@ -8,7 +8,7 @@ module.exports = { const newnick = args.slice(0).join(" ") try { await message.member.setNickname(newnick, "Nickname change requested by the server member. If you don't want users to be able to change their nickname disable 'CHANGE_NICKNAME' via Change Nickname in Roles.") - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:AnitroxSuccess:809651936819019796> Nickname Changed", "color": 9442302, "footer": { @@ -26,7 +26,7 @@ module.exports = { "inline": true } ] - }}); + }]}); } catch (error) { await message.channel.send(client.generateErrorMessage("Failed to set user nickname. Does the bot have the correct permissions?", message.author.displayAvatarURL())); }; diff --git a/commands/slap.js b/commands/slap.js index f390d06..77a2062 100644 --- a/commands/slap.js +++ b/commands/slap.js @@ -9,7 +9,7 @@ module.exports = { if(!taggedUser) { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": ":anger: Slap", "description": `${taggedUser} You have been slapped by ${message.author}!`, "color": 9442302, @@ -20,7 +20,7 @@ module.exports = { "image": { "url": "https://media1.tenor.com/images/b6d8a83eb652a30b95e87cf96a21e007/tenor.gif?itemid=10426943" } - }}); + }]}); } } } diff --git a/commands/snuggle.js b/commands/snuggle.js index e94afb9..541e991 100644 --- a/commands/snuggle.js +++ b/commands/snuggle.js @@ -17,7 +17,7 @@ module.exports = { await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { const gif = gifchoices[Math.floor(Math.random() * gifchoices.length)]; - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:BlobSnuggleCat:806759753450782731> Snuggle", "description": `${taggedUser} You have been snuggled by ${message.author}!`, "color": 9442302, @@ -28,7 +28,7 @@ module.exports = { "image": { "url": gif } - }}); + }]}); } } } \ No newline at end of file diff --git a/commands/stop.js b/commands/stop.js index 9e11f13..9dee70e 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -5,7 +5,7 @@ module.exports = { async execute(_0, message, _1, config) { if (message.author.id == config.ownerID) { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": " **Shutting Down...**", "description": "See you next time!", "color": 9442302, @@ -13,11 +13,11 @@ module.exports = { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt }, - }}); + }]}); console.log("The bot is shutting down! Bye bye!") process.exit(); } else { - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": "<:AnitroxDenied:809651936642203668> 403 Forbidden", "description": "You need to be the bot owner to execute this command!", "color": 13632027, @@ -25,7 +25,7 @@ module.exports = { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt }, - }}); + }]}); } } } \ No newline at end of file diff --git a/commands/uinfo.js b/commands/uinfo.js index aa20282..f42125e 100644 --- a/commands/uinfo.js +++ b/commands/uinfo.js @@ -7,7 +7,7 @@ module.exports = { async execute(client, message, args, config) { const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author - await message.channel.send({embed: { + await message.channel.send({embeds: [{ "title": `Everything you've ever wanted to know about ${user.username}!`, "color": 9442302, "footer": { @@ -52,6 +52,6 @@ module.exports = { inline: true }, ] - }}); + }]}); } } diff --git a/config-example.json b/config-example.json index 47afd8f..d61c748 100644 --- a/config-example.json +++ b/config-example.json @@ -53,5 +53,9 @@ "Go for it! :smile:", "Good idea!", "Sure" + ], + "intents": [ + "GUILDS", + "GUILD_MESSAGES" ] } \ No newline at end of file diff --git a/package.json b/package.json index 45ac005..55d9b35 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Discord Bot Based on Discord.JS", "main": "start.js", "dependencies": { - "discord.js": "^12.5.1", + "discord.js": "^13.6.0", "node-os-utils": "^1.3.2", "require-all": "^3.0.0" }, diff --git a/start.js b/start.js index 483f924..6b20004 100755 --- a/start.js +++ b/start.js @@ -4,7 +4,7 @@ const fs = require('fs'); const Discord = require('discord.js'); const config = require('./config.json'); console.log('Starting!') -const client = new Discord.Client(); +const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`))}); client.commands = new Discord.Collection(); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); @@ -14,7 +14,7 @@ for (const file of commandFiles) { client.commands.set(command.name, command); } -client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embed: { +client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embeds: [{ "title": "<:AnitroxError:809651936563429416> Error", "color": 13632027, "footer": { @@ -27,7 +27,7 @@ client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embed: { "value": errorMsg } ] -}}) +}]}) client.on("error", (e) => console.log(`[ERROR] ${error(e)}`)); client.on("warn", (e) => (`[WARN] ${warn(e)}`)); @@ -51,7 +51,7 @@ client.once('ready', () => { // Begin Command Handler -client.on('message', async (message) => { +client.on('messageCreate', async (message) => { if (!message.content.startsWith(config.prefix) || message.author.bot) return; @@ -64,7 +64,7 @@ client.on('message', async (message) => { await client.commands.get(command).execute(client, message, args, config); } catch (error) { console.stack; - message.channel.send({embed: { + message.channel.send({embeds: [{ "title": "<:AnitroxError:809651936563429416> **Something went wrong!**", "description": error.stack, "color": 13632027, @@ -72,7 +72,7 @@ client.on('message', async (message) => { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt }, - }}); + }]}); } });