From 4d51f2b5a7936a4f2140c31f19abd5c69959b5e6 Mon Sep 17 00:00:00 2001 From: Nathaniel Mason Date: Sat, 26 Mar 2022 17:31:03 +0000 Subject: [PATCH] new error embed generator + some more patches --- commands/8ball.js | 15 +++++-------- commands/avatar.js | 9 +++++--- commands/bonk.js | 22 +++++-------------- commands/cheese.js | 9 +++++--- commands/cuddle.js | 9 +++++--- commands/eval.js | 7 ++++-- commands/help.js | 7 ++++-- commands/hug.js | 22 +++++-------------- commands/info.js | 7 ++++-- commands/invite.js | 7 ++++-- commands/kiss.js | 19 +++++----------- commands/leskiss.js | 19 +++++----------- commands/lick.js | 21 ++++++------------ commands/nom.js | 21 ++++++------------ commands/opensource.js | 7 ++++-- commands/pat.js | 21 ++++++------------ commands/ping.js | 7 ++++-- commands/poke.js | 21 ++++++------------ commands/reload.js | 50 ++++++++++++++++++++++++------------------ commands/setnick.js | 23 ++++++++----------- commands/slap.js | 21 ++++++------------ commands/snuggle.js | 22 +++++++------------ commands/stop.js | 12 +++++++--- commands/uinfo.js | 8 ++++--- start.js | 31 ++++++++++++++++++-------- 25 files changed, 195 insertions(+), 222 deletions(-) diff --git a/commands/8ball.js b/commands/8ball.js index 393aba5..13893ec 100644 --- a/commands/8ball.js +++ b/commands/8ball.js @@ -23,24 +23,21 @@ module.exports = { name: '8ball', description: 'Ask Anitrox a question, any question! and they will answer it!', syntax: ["[Question]"], - async execute(_, message, args, footer) { + async execute(client, message, args, footerTxt) { const answer = answers[Math.floor(Math.random() * Object.keys(answers).length)]; const question = args.slice(0).join(" ") - console.log(args); if (!question) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> **Something went wrong!**", - "description": "You need to ask a question!", - "color": 13632027, - "footer": footer - }}); + await message.channel.send(client.generateErrorMessage("You need to ask a question!", message.author.displayAvatarURL)); } else { await message.channel.send({embed: { "title": ":8ball: Anitrox 8 Ball", "description": "Your question: **" + question + "**", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "fields": [ { "name": "🤔 My Answer", diff --git a/commands/avatar.js b/commands/avatar.js index 7d4b3ea..a4a02ff 100644 --- a/commands/avatar.js +++ b/commands/avatar.js @@ -2,14 +2,17 @@ module.exports = { name: "avatar", description: "Gets a user's avatar.", - async execute(_0, message, _1, footer) { + async execute(client, message, args, footerTxt) { - const user = message.mentions.users.first() || message.author; + const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author; await message.channel.send({embed: { "title": ":frame_photo: " + user.username + "'s Beautiful Avatar!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": user.displayAvatarURL() } diff --git a/commands/bonk.js b/commands/bonk.js index c4236cf..fa6ee22 100644 --- a/commands/bonk.js +++ b/commands/bonk.js @@ -2,30 +2,20 @@ module.exports = { name: "bonk", description: "Bonks a user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 13632027, - "footer": { - "icon_url": "https://images-ext-2.discordapp.net/external/-qaO3jaZLojhEnjrHiKABdXD7gLWqFvdUqHdskNGWhE/https/media.discordapp.net/attachments/549707869138714635/793524910172667964/Screenshot_26.png", - "text": "Made with ❤ in Illinois | Anitrox by IDeletedSystem64" - }, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { await message.channel.send({embed: { "title": " Bonk", "description": "<@" + taggedUser + ">" + " You have been bonked by <@" + message.author + ">!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": "https://cdn.discordapp.com/attachments/793537380330111028/801194481549312060/HappyBONK.gif" } diff --git a/commands/cheese.js b/commands/cheese.js index 9a0ea45..533eb41 100644 --- a/commands/cheese.js +++ b/commands/cheese.js @@ -1,16 +1,19 @@ module.exports = { name: "cheese", description: "Cheese an user, or run just ``n!cheese`` for a surprise :eyes:", - async execute(_0, message, _1, footer) { + async execute(_0, message, _1, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send("*slams cheese on desk* Cheese. https://www.youtube.com/watch?v=Or4IE8fkpn4"); + await message.channel.send("*slams cheese on desk*\n**Cheese.** https://www.youtube.com/watch?v=Or4IE8fkpn4"); } else { await message.channel.send({embed: { "title": ":cheese: Cheesed", "description": "<@" + taggedUser + ">" + " You got cheesed by " + "<@" + message.author + ">!", "color": 16312092, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/812867714368536636/R06325af354168febcafd96b8328b7590.png" } diff --git a/commands/cuddle.js b/commands/cuddle.js index f102261..d7d017a 100644 --- a/commands/cuddle.js +++ b/commands/cuddle.js @@ -9,20 +9,23 @@ module.exports = { name: "cuddle", description: "Cuddle an user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); const index = Math.floor(Math.random() * gifchoices.length); const gif = (gifchoices[index]); if(!taggedUser) { - await message.channel.send("<:AnitroxError:809651936563429416> You need to specify an user!"); + await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { await message.channel.send({embed: { "title": ":heart: Cuddle", "description": "<@" + taggedUser + ">" + " You have been cuddled by " + "<@" + message.author + ">!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/eval.js b/commands/eval.js index 529a432..b94dde9 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -4,7 +4,7 @@ module.exports = { name: 'eval', description: 'Runs js code', - async execute(_, message, args, footer) { + async execute(_, message, args, footerTxt) { if (message.author.id == 309427567004483586 || message.author.id == 475558313376088064) { try { const code = args.join(" "); @@ -14,7 +14,10 @@ module.exports = { await message.channel.send({embed: { "title": "<:NyabotError:697145462347661412> **Well that happened...**", "color": 13632027, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "fields": [ { "name": "**What Happened?**", diff --git a/commands/help.js b/commands/help.js index ccd12c6..6939ba5 100644 --- a/commands/help.js +++ b/commands/help.js @@ -4,12 +4,15 @@ module.exports = { description: 'Get help on anything from commands, to what the bot does! just not your homework..', syntax: '', - async execute(_0, message, _1, footer) { + async execute(_0, message, _1, footerTxt) { await message.channel.send({embed: { "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, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + " | No mother it's just the northern lights" + }, "fields": [ { "name": "Command List", diff --git a/commands/hug.js b/commands/hug.js index 402ced8..3e1730f 100644 --- a/commands/hug.js +++ b/commands/hug.js @@ -10,31 +10,21 @@ module.exports = { name: "hug", description: "Hugs a user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": { - "icon_url": message.author.displayAvatarURL(), - "text": message.author.displayAvatarURL() - }, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": " Hug", "description": "<@" + taggedUser + ">" + " You have been hugged by " + "<@" + message.author + ">!", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/info.js b/commands/info.js index 6a39d70..0ef4fd2 100644 --- a/commands/info.js +++ b/commands/info.js @@ -4,7 +4,7 @@ module.exports = { name: 'info', description: 'Shows bot and host information', - async execute(client, message, _, footer) { + async execute(client, message, _, footerTxt) { function Uptime(uptime) { const totalSeconds = (uptime / 1000); @@ -29,7 +29,10 @@ module.exports = { "title": "<:AnitroxInfo:809651936831733791> Information about Anitrox", "description": "Everything you've ever wanted to know about your favorite bot, Anitrox!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "thumbnail": { "url": client.user.displayAvatarURL() }, diff --git a/commands/invite.js b/commands/invite.js index 78b4acf..ce04d12 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -3,12 +3,15 @@ module.exports = { name: 'invite', description: 'Add Anitrox to your beautiful server!', syntax: [], - async execute(_0, message, _1, footer) { + async execute(_0, message, _1, footerTxt) { await message.channel.send({embed: { "title": "Add Anitrox to your Server!", "description": "Weather you want stable, or that squeaky clean fresh PTB build, we gotchu.", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "thumbnail": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/814352905394061322/anitroxaddsrvr.png" }, diff --git a/commands/kiss.js b/commands/kiss.js index fe5efd8..f8cd102 100644 --- a/commands/kiss.js +++ b/commands/kiss.js @@ -10,28 +10,21 @@ module.exports = { name: "kiss", description: "Kisses a user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 13632027, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": ":heart: Kiss", "description": "<@" + taggedUser + ">" + ", You have been kissed by <@" + message.author + ">!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/leskiss.js b/commands/leskiss.js index c16f007..45192f7 100644 --- a/commands/leskiss.js +++ b/commands/leskiss.js @@ -20,28 +20,21 @@ module.exports = { name: "leskiss", description: "Lesbian kiss <:lesbian:803831629428686849>", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": ":heart: <:lesbian:803831629428686849> Kiss", "description": "<@" + taggedUser + ">" + " You have been kissed by <@" + message.author + ">! <:lesbian:803831629428686849>", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/lick.js b/commands/lick.js index 21b4c5d..b7a4748 100644 --- a/commands/lick.js +++ b/commands/lick.js @@ -8,29 +8,22 @@ const gifchoices = [ module.exports = { name: "lick", - description: "Licks an user!", - async execute(_0, message, _1, footer) { + description: "Licks a user!", + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": " Lick", "description": "<@" + taggedUser + "> You have been licked by <@" + message.author + ">!", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/805314244123951114/cef569820773b0f5d54ee34cfa18e1f8.gif" } diff --git a/commands/nom.js b/commands/nom.js index 19857a7..ebb5ce4 100644 --- a/commands/nom.js +++ b/commands/nom.js @@ -9,28 +9,21 @@ module.exports = { name: "nom", description: "Noms an user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": "<:BlobNomBlob:801241117919805510> Nom", - "description": "<@" + taggedUser + "> You have been nommed by <@" + messageAuthor + ">!", + "description": "<@" + taggedUser + "> You have been nommed by <@" + message.author + ">!", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/opensource.js b/commands/opensource.js index 1c52f85..8b14c43 100644 --- a/commands/opensource.js +++ b/commands/opensource.js @@ -1,12 +1,15 @@ module.exports = { name: 'opensource', description: 'Attributions to open source components used by Anitrox', - async execute(_0, message, _1, footer){ + async execute(_0, message, _1, footerTxt){ await message.channel.send({embed: { "title": "Component Attribution", "description": "Some parts of Anitrox are using open source code, and their attributions are avaliable here!", "color": 52508, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "thumbnail": { "url": "https://cdn.discordapp.com/attachments/803658122299572255/838854256471703602/793885335498522685.png" }, diff --git a/commands/pat.js b/commands/pat.js index d5024a3..af031b5 100644 --- a/commands/pat.js +++ b/commands/pat.js @@ -8,28 +8,21 @@ module.exports = { name: "pat", description: "Pats a user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": "<:pats:801238281286713355> Pat", - "description": "<@" + taggedUser + "> You have been patted by <@" + messageAuthor + ">!", + "description": "<@" + taggedUser + "> You have been patted by <@" + message.author + ">!", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/ping.js b/commands/ping.js index 57b20c5..ef253d2 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -3,7 +3,7 @@ const { locations } = require('../config.json'); module.exports = { name: "ping", description: "Gets bot ping", - async execute(client, message, _, footer) { + async execute(client, message, _, footerTxt) { const index = Math.floor(Math.random() * locations.length); const pingLocation = locations[index] @@ -11,7 +11,10 @@ module.exports = { "title": ":ping_pong: Ping", "description": "**Pong!** We pinged **" + pingLocation + "** and got " + client.ws.ping + " ms.", "color": 9442302, - "footer": footer + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + } }}); } }; diff --git a/commands/poke.js b/commands/poke.js index f338634..9334db8 100644 --- a/commands/poke.js +++ b/commands/poke.js @@ -7,29 +7,22 @@ const gifchoices = [ module.exports = { name: "poke", - description: "Pokes an user!", - async execute(_0, message, _1, footer) { + description: "Pokes a user!", + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 9442302, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": "👉 Poke!", "description": "<@" + taggedUser + "> You have been poked by <@" + message.author + ">!", "color": 8311585, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/reload.js b/commands/reload.js index b8e1e09..b04dbba 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -1,33 +1,41 @@ module.exports = { name: 'reload', description: 'Reloads a command', - args: true, - async execute(client, message, args, footer) { + async execute(client, message, args, footerTxt) { if (message.author.id == 309427567004483586 || message.author.id == 475558313376088064) { - const commandName = args[0].toLowerCase(); - const command = message.client.commands.get(commandName) - || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)); - - if (!command) { - await message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`); - } else { - delete require.cache[require.resolve(`./${command.name}.js`)]; - - try { - const newCommand = require(`./${command.name}.js`); - client.commands.set(newCommand.name, newCommand); - await message.channel.send(`<:NyabotSuccess:697211376740859914> **Reloaded \`${command.name}\` successfully!**`); - console.log(`User reloaded ${command.name}.`) - } catch (error) { - console.error(error); - await message.channel.send(`<:AnitroxError:809651936563429416> There was an error while reloading \`${command.name}\`:\n\`${error.message}\``); - } + if (!args.length) { + await message.channel.send(client.generateErrorMessage("You forgot to provide anything to reload, you pillock",message.author.displayAvatarURL())); } + args.forEach(async (arg) => { + const commandName = arg.toLowerCase(); + const command = message.client.commands.get(commandName) + || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)); + + if (!command) { + await message.channel.send(client.generateErrorMessage(`There is no command with name or alias \`${commandName}\`, ${message.author}!`,message.author.displayAvatarURL())); + } else { + delete require.cache[require.resolve(`./${command.name}.js`)]; + + try { + const newCommand = require(`./${command.name}.js`); + client.commands.set(newCommand.name, newCommand); + await message.channel.send(`<:NyabotSuccess:697211376740859914> **Reloaded \`${command.name}\` successfully!**`); + console.log(`User reloaded ${command.name}.`) + } catch (error) { + console.error(error); + await message.channel.send(client.generateErrorMessage(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``, message.author.displayAvatarURL())); + } + } + }); + } else { message.channel.send({embed: { "title": "<:NyabotDenied:697145462565896194> **Access is denied**", "color": 13632027, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "fields": [ { "name": "**What Happened?**", diff --git a/commands/setnick.js b/commands/setnick.js index 1d1d204..efa1e1c 100644 --- a/commands/setnick.js +++ b/commands/setnick.js @@ -1,7 +1,7 @@ module.exports = { name: 'setnick', description: 'Sets your nickname', - async execute(_, message, args, footer) { + async execute(client, message, args, footerTxt) { if (message.channel.permissionsFor(message.author).has("CHANGE_NICKNAME")) { const newnick = args.slice(0).join(" ") @@ -11,7 +11,10 @@ module.exports = { await message.channel.send({embed: { "title": "<:AnitroxSuccess:809651936819019796> Nickname Changed", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "fields": [ { "name": "Changed nickname successfully!", @@ -25,18 +28,10 @@ module.exports = { ] }}); } catch (error) { - await message.channel.send({embed: { - "title": "<:AnitroxDenied:809651936642203668> Well that happened...", - "color": 13632027, - "footer": footer, - "fields": [ - { - "name": "Failed to set nickname", - "value": "You need to have permission ``CHANGE_NICKNAME`` to change your nick!" - } - ] - }}); + await message.channel.send(client.generateErrorMessage("Failed to set user nickname. Does the bot have the correct permissions?", message.author.displayAvatarURL())); }; - }; + } else { + await message.channel.send(client.generateErrorMessage("You need to have permission ``CHANGE_NICKNAME`` to change your nick!", message.author.displayAvatarURL())); + } } } diff --git a/commands/slap.js b/commands/slap.js index 9f57976..0f1564b 100644 --- a/commands/slap.js +++ b/commands/slap.js @@ -2,27 +2,20 @@ module.exports = { name: "slap", description: "Slaps an user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 13632027, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + await message.channel.send(client.generateErrorMessage("You need to @mention a user!", message.author.displayAvatarURL())); } else { await message.channel.send({embed: { "title": ":anger: Slap", - "description": "<@" + taggedUser + "> You have been slapped by <@" + messageAuthor + ">!", + "description": "<@" + taggedUser + "> You have been slapped by <@" + message.author + ">!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": "https://media1.tenor.com/images/b6d8a83eb652a30b95e87cf96a21e007/tenor.gif?itemid=10426943" } diff --git a/commands/snuggle.js b/commands/snuggle.js index f9f0e51..b90a0cb 100644 --- a/commands/snuggle.js +++ b/commands/snuggle.js @@ -9,27 +9,21 @@ module.exports = { name: "snuggle", description: "Snuggle an user!", - async execute(_0, message, _1, footer) { + async execute(client, message, _, footerTxt) { const taggedUser = message.mentions.users.first(); if(!taggedUser) { - await message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> Error", - "color": 13632027, - "footer": footer, - "fields": [ - { - "name": "Well that happened...", - "value": "You need to @mention an user!" - } - ] - }}); + 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: { "title": "<:BlobSnuggleCat:806759753450782731> Snuggle", - "description": "<@" + taggedUser + ">" + " You have been snuggled by " + "<@" + messageAuthor + ">!", + "description": "<@" + taggedUser + ">" + " You have been snuggled by " + "<@" + message.author + ">!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "image": { "url": gif } diff --git a/commands/stop.js b/commands/stop.js index 72e5d4d..a106573 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -1,13 +1,16 @@ module.exports = { name: "stop", description: "Stops the bot", - async execute(client, message, _, footer) { + async execute(client, message, _, footerTxt) { if (message.author.id == 309427567004483586 || message.author.id == 475558313376088064) { await message.channel.send({embed: { "title": " **Shutting Down...**", "description": "See you next time!", "color": 9442302, - "footer": footer + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, }}); client.destroy(); } else { @@ -15,7 +18,10 @@ module.exports = { "title": ":AnitroxDenied: Access Denied", "description": "You need to be the bot owner to execute this command!", "color": 13632027, - "footer": footer + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, }}); } } diff --git a/commands/uinfo.js b/commands/uinfo.js index 31e735f..138c8a7 100644 --- a/commands/uinfo.js +++ b/commands/uinfo.js @@ -2,13 +2,15 @@ module.exports = { name: "uinfo", description: "Gets info about an user, such as ID, Discord Join date and more", syntax: "", - async execute(client, message, args, footer) { - console.log(args[0]) + async execute(client, message, args, footerTxt) { const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author await message.channel.send({embed: { "title": "Everything you've ever wanted to know about " + user.username + "!", "color": 9442302, - "footer": footer, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, "thumbnail": { "url": user.displayAvatarURL() }, diff --git a/start.js b/start.js index 4d2a77a..e823731 100755 --- a/start.js +++ b/start.js @@ -4,11 +4,6 @@ const fs = require('fs'); const Discord = require('discord.js'); const { statuses, build, release, prefix, token, footerTxt } = require('./config.json'); -const embedFooter = { - "icon_url": "https://cdn.discordapp.com/attachments/549707869138714635/793524910172667964/Screenshot_26.png", - "text": footerTxt -} - console.log('Starting!') const client = new Discord.Client(); client.commands = new Discord.Collection(); @@ -20,6 +15,21 @@ for (const file of commandFiles) { client.commands.set(command.name, command); } +client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embed: { + "title": "<:AnitroxError:809651936563429416> Error", + "color": 13632027, + "footer": { + "icon_url": messageAuthorURL, + "text": footerTxt + }, + "fields": [ + { + "name": "Well that happened...", + "value": errorMsg + } + ] +}}) + client.on("error", (e) => console.log("[ERROR]" + error(e))); client.on("warn", (e) => ("[WARN]" + warn(e))); client.once('ready', () => { @@ -51,15 +61,18 @@ client.on('message', async (message) => { if (!client.commands.has(command)) return; try { - await client.commands.get(command).execute(client, message, args, embedFooter); + await client.commands.get(command).execute(client, message, args, footerTxt); } catch (error) { console.stack; - message.channel.send(new Discord.MessageEmbed({ + message.channel.send({embed: { "title": "<:AnitroxError:809651936563429416> **Something went wrong!**", "description": error.stack, "color": 13632027, - "footer": footer - })); + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": footerTxt + }, + }}); } });