From 8b889c7210c71fd6465181a22d138a131094a026 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 22 Nov 2019 12:30:20 +0100 Subject: [PATCH] Use discord-akairo embed --- commands/fun/4chan.js | 3 +-- commands/fun/reddit.js | 3 +-- commands/general/advice.js | 3 +-- commands/general/say.js | 3 +-- commands/general/tweet.js | 5 ++--- commands/minigame/borgar.js | 5 ++--- commands/minigame/guess.js | 3 +-- commands/owner/eval.js | 5 ++--- commands/owner/update.js | 3 +-- commands/utility/about.js | 3 +-- commands/utility/donate.js | 3 +-- commands/utility/download.js | 3 +-- commands/utility/feedback.js | 3 +-- commands/utility/seebannedword.js | 3 +-- commands/utility/seetag.js | 8 +++----- commands/utility/server.js | 3 +-- commands/utility/stats.js | 4 ++-- commands/utility/translate.js | 3 +-- commands/utility/updoot.js | 3 +-- commands/utility/userInfo.js | 3 +-- event/listeners/guildCreate.js | 3 +-- event/listeners/guildDelete.js | 3 +-- event/listeners/message.js | 5 ++--- event/listeners/messageReactionAdd.js | 3 +-- 24 files changed, 31 insertions(+), 55 deletions(-) diff --git a/commands/fun/4chan.js b/commands/fun/4chan.js index f9ee7a7d..7518b4c3 100644 --- a/commands/fun/4chan.js +++ b/commands/fun/4chan.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); const boards = require('4chan-boards'); const htmlToText = require('html-to-text'); @@ -62,7 +61,7 @@ class FourchanCommand extends Command { title = 'No title'; } - const FourchanEmbed = new MessageEmbed() + const FourchanEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(title) .setDescription(htmlToText.fromString(description)) diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index 8c9958ae..175ec96b 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); class RedditCommand extends Command { @@ -43,7 +42,7 @@ class RedditCommand extends Command { let i = Math.floor((Math.random() * response.data.children.length)); if (response.data.children[i].data.over_18 == true && !message.channel.nsfw) return message.channel.send('No nsfw'); - const redditEmbed = new MessageEmbed() + const redditEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(response.data.children[i].data.title) .setDescription(response.data.children[i].data.selftext) diff --git a/commands/general/advice.js b/commands/general/advice.js index 539fecbe..14991784 100644 --- a/commands/general/advice.js +++ b/commands/general/advice.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); class AdviceCommand extends Command { @@ -20,7 +19,7 @@ class AdviceCommand extends Command { fetch('http://api.adviceslip.com/advice').then((response) => { return response.json(); }).then((response) => { - const adviceEmbed = new MessageEmbed() + const adviceEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(response.slip.slip_id) .setDescription(response.slip.advice); diff --git a/commands/general/say.js b/commands/general/say.js index 31b19f26..a1419234 100644 --- a/commands/general/say.js +++ b/commands/general/say.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const rand = require('../../rand.js'); class SayCommand extends Command { @@ -130,7 +129,7 @@ class SayCommand extends Command { } } - const embed = new MessageEmbed() + const embed = this.client.util.embed() .setColor(color) .setTitle(title) .setImage(image) diff --git a/commands/general/tweet.js b/commands/general/tweet.js index 095af8ac..aa009c9c 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -1,7 +1,6 @@ const { Command } = require('discord-akairo'); const Twitter = require('twitter-lite'); const rand = require('../../rand.js'); -const { MessageEmbed } = require('discord.js'); //const Filter = require('bad-words'); //let filter = new Filter(); const TwitterBlacklist = require('../../models').TwitterBlacklist; @@ -84,7 +83,7 @@ class tweetCommand extends Command { const tweetid = response.id_str; - const publicEmbed = new MessageEmbed() + const publicEmbed = this.client.util.embed() .setAuthor('Some user of discord said...') .setDescription(args.text) .addField('Link', `https://twitter.com/HahaYesDB/status/${tweetid}`) @@ -94,7 +93,7 @@ class tweetCommand extends Command { let channel = this.client.channels.get('597964498921455637'); channel.send({embed: publicEmbed}); - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setAuthor(message.author.username, message.author.displayAvatarURL()) .setDescription(args.text) .addField('Link', `https://twitter.com/HahaYesDB/status/${tweetid}`, true) diff --git a/commands/minigame/borgar.js b/commands/minigame/borgar.js index 166517f5..d31b8258 100644 --- a/commands/minigame/borgar.js +++ b/commands/minigame/borgar.js @@ -2,7 +2,6 @@ // Higher the level the less time you have to complete it // Make the command less shit const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const borgar = require('../../models').borgar; class borgarCommand extends Command { @@ -57,7 +56,7 @@ class borgarCommand extends Command { hamIngredient.push('bun'); - let borgarEmbed = new MessageEmbed() + let borgarEmbed = this.client.util.embed() .setTitle('hamborger info') .setDescription(`could you do me an **amborgar** that contain **${hamIngredient}**`) .setFooter(`Level ${level} | Once the ingredients dissapear you have 10 seconds to do it!`) @@ -66,7 +65,7 @@ class borgarCommand extends Command { message.util.send(borgarEmbed) .then(() => { setTimeout(async () => { - borgarEmbed = new MessageEmbed() + borgarEmbed = this.client.util.embed() .setTitle('hamborger delivery') .setDescription('You have to put each ingredients in seperate messages!') .setFooter(`Level ${level} | you have 10 seconds to make that hamborgor`) diff --git a/commands/minigame/guess.js b/commands/minigame/guess.js index 5087f2c6..48bd23fa 100644 --- a/commands/minigame/guess.js +++ b/commands/minigame/guess.js @@ -1,6 +1,5 @@ const { Command } = require('discord-akairo'); const guessLeaderboard = require('../../models').guessLeaderboard; -const { MessageEmbed } = require('discord.js'); class guessCommand extends Command { constructor() { @@ -36,7 +35,7 @@ class guessCommand extends Command { if (args.leaderboard) { const leaderboard = await guessLeaderboard.findAll({order: ['try']}); let top = []; - let leaderboardEmbed = new MessageEmbed() + let leaderboardEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('Guess leaderboard'); for (let i = 0; i < leaderboard.length; i++) { diff --git a/commands/owner/eval.js b/commands/owner/eval.js index 9d855dc0..17b60f96 100644 --- a/commands/owner/eval.js +++ b/commands/owner/eval.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); class EvalCommand extends Command { constructor() { @@ -37,7 +36,7 @@ class EvalCommand extends Command { if (typeof evaled !== 'string') evaled = require('util').inspect(evaled); - const evalEmbed = new MessageEmbed() + const evalEmbed = this.client.util.embed() .setColor('#00FF00') .setTitle(' Eval succes ') .setThumbnail('https://cdn4.iconfinder.com/data/icons/gradient-ui-1/512/success-512.png') @@ -47,7 +46,7 @@ class EvalCommand extends Command { message.channel.send(evalEmbed); } catch (err) { - const errorEmbed = new MessageEmbed() + const errorEmbed = this.client.util.embed() .setColor('#FF0000') .setTitle('Eval failed <:sadpepe:534399181679230986>') .setThumbnail('https://cdn4.iconfinder.com/data/icons/the-weather-is-nice-today/64/weather_48-512.png') diff --git a/commands/owner/update.js b/commands/owner/update.js index cff3cff4..d96a84a4 100644 --- a/commands/owner/update.js +++ b/commands/owner/update.js @@ -1,7 +1,6 @@ const { Command } = require('discord-akairo'); const util = require('util'); const exec = util.promisify(require('child_process').exec); -const { MessageEmbed } = require('discord.js'); class EvalCommand extends Command { constructor() { @@ -20,7 +19,7 @@ class EvalCommand extends Command { async exec(message) { async function update() { const { stdout, stderr } = await exec('git pull'); - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .addField('stdout', stdout) .addField('stderr', stderr); message.channel.send({embed: Embed}); diff --git a/commands/utility/about.js b/commands/utility/about.js index 1f19b798..6fe7deb8 100644 --- a/commands/utility/about.js +++ b/commands/utility/about.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const { ownerID } = require('../../config.json'); const donator = require('../../models').donator; @@ -31,7 +30,7 @@ class aboutCommand extends Command { } - const aboutEmbed = new MessageEmbed() + const aboutEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setAuthor(this.client.user.username, this.client.user.avatarURL()) .setTitle('About me') diff --git a/commands/utility/donate.js b/commands/utility/donate.js index db129003..37e57ab1 100644 --- a/commands/utility/donate.js +++ b/commands/utility/donate.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); class donateCommand extends Command { constructor() { @@ -16,7 +15,7 @@ class donateCommand extends Command { } async exec(message) { - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('Donation link') .setDescription('If you decide to donate, please use the feedback command to let the owner know about it so he can put you in the about and donator command\n[Paypal](https://www.paypal.me/supositware)\n[Patreon](https://www.patreon.com/bePatron?u=15330358)\n[Brave referal program](https://brave.com/hah459)\nTip me with Brave BAT token on [my website](https://namejeff.xyz/)'); diff --git a/commands/utility/download.js b/commands/utility/download.js index ef92419f..35198853 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -3,7 +3,6 @@ const fs = require('fs'); const youtubedl = require('youtube-dl'); const hbjs = require('handbrake-js'); const os = require('os'); -const { MessageEmbed } = require('discord.js'); class DownloadCommand extends Command { constructor() { @@ -51,7 +50,7 @@ class DownloadCommand extends Command { } - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setColor(message.member.displayHexColor) .setAuthor(`Downloaded by ${message.author.username}`, message.author.displayAvatarURL(), link) .setDescription(args.caption) diff --git a/commands/utility/feedback.js b/commands/utility/feedback.js index 85627fcc..61222793 100644 --- a/commands/utility/feedback.js +++ b/commands/utility/feedback.js @@ -1,6 +1,5 @@ const { Command } = require('discord-akairo'); const { feedbackChannel } = require('../../config.json'); -const { MessageEmbed } = require('discord.js'); class FeedbackCommand extends Command { constructor() { @@ -35,7 +34,7 @@ class FeedbackCommand extends Command { const channel = this.client.channels.get(feedbackChannel); - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setAuthor(`${message.author.username} (${message.author.id})`, message.author.displayAvatarURL()) .addField('Guild', `${message.guild.name} (${message.guild.id})`, true) .addField('Feedback', args.text) diff --git a/commands/utility/seebannedword.js b/commands/utility/seebannedword.js index c30e36a1..43800106 100644 --- a/commands/utility/seebannedword.js +++ b/commands/utility/seebannedword.js @@ -1,6 +1,5 @@ const { Command } = require('discord-akairo'); const BannedWords = require('../../models').bannedWords; -const { MessageEmbed } = require('discord.js'); class seebannedwordCommand extends Command { @@ -31,7 +30,7 @@ class seebannedwordCommand extends Command { if (list == undefined) return message.channel.send('No word are banned yet.'); - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('List of banned words') .setDescription(list); diff --git a/commands/utility/seetag.js b/commands/utility/seetag.js index f9b15ac6..dfa045ea 100644 --- a/commands/utility/seetag.js +++ b/commands/utility/seetag.js @@ -2,8 +2,6 @@ const { Command } = require('discord-akairo'); const Tag = require('../../models').Tag; const fs = require('fs'); const os = require('os'); -const { MessageEmbed } = require('discord.js'); - class seetagCommand extends Command { constructor() { @@ -38,7 +36,7 @@ class seetagCommand extends Command { if (!tagList) return message.channel.send('Tag not found.'); this.client.users.fetch(tagList.dataValues.ownerID) .then(user => { - const TagEmbed = new MessageEmbed() + const TagEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(message.guild.name) .addField('Trigger:', tagList['dataValues']['trigger']) @@ -54,7 +52,7 @@ class seetagCommand extends Command { }); }) .catch(() => { - const TagEmbed = new MessageEmbed() + const TagEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(message.guild.name) .addField('Trigger:', tagList['dataValues']['trigger']) @@ -83,7 +81,7 @@ class seetagCommand extends Command { } else { let tagList = await Tag.findAll({attributes: ['trigger'], where: {serverID: message.guild.id}}); const tagString = tagList.map(t => t.trigger).join(', ') || 'No tags set.'; - const TagEmbed = new MessageEmbed() + const TagEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('List of tags') .setDescription(tagString) diff --git a/commands/utility/server.js b/commands/utility/server.js index 139a44e5..64365bf8 100644 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); class ServerCommand extends Command { constructor() { @@ -17,7 +16,7 @@ class ServerCommand extends Command { } async exec(message) { - const addEmbed = new MessageEmbed() + const addEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle(message.guild.name) .setThumbnail(message.guild.iconURL()) diff --git a/commands/utility/stats.js b/commands/utility/stats.js index fc515ebd..ba754964 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -1,6 +1,6 @@ const { Command } = require('discord-akairo'); const akairoVersion = require('discord-akairo').version; -const { MessageEmbed, version } = require('discord.js'); +const { version } = require('discord.js'); const util = require('util'); const exec = util.promisify(require('child_process').exec); @@ -51,7 +51,7 @@ class StatsCommand extends Command { cpu = stdout.replace('Name', ''); } - const statsEmbed = new MessageEmbed() + const statsEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('Bot stats') .setAuthor('Haha yes') diff --git a/commands/utility/translate.js b/commands/utility/translate.js index 3575ea96..21d43a0c 100644 --- a/commands/utility/translate.js +++ b/commands/utility/translate.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); const { yandexAPI } = require('../../config.json'); @@ -51,7 +50,7 @@ class TranslationCommand extends Command { return message.channel.send('An error has occured'); - const translationEmbed = new MessageEmbed() + const translationEmbed = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('Asked for the following translation:') .setAuthor(message.author.username) diff --git a/commands/utility/updoot.js b/commands/utility/updoot.js index 470f0fad..276771eb 100644 --- a/commands/utility/updoot.js +++ b/commands/utility/updoot.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); class UpdootCommand extends Command { constructor() { @@ -17,7 +16,7 @@ class UpdootCommand extends Command { } async exec(message) { - const upDoot = new MessageEmbed() + const upDoot = this.client.util.embed() .setColor(message.member.displayHexColor) .setTitle('Vote for my bot') .setAuthor(message.author.username) diff --git a/commands/utility/userInfo.js b/commands/utility/userInfo.js index 2519c4f2..b438542b 100644 --- a/commands/utility/userInfo.js +++ b/commands/utility/userInfo.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); class userInfoCommand extends Command { constructor() { @@ -31,7 +30,7 @@ class userInfoCommand extends Command { let member = message.guild.member(user); - const Embed = new MessageEmbed() + const Embed = this.client.util.embed() .setColor(member.displayHexColor) .setAuthor(`${user.tag} (${user.id})`, user.displayAvatarURL()) .addField('Current rank hex color', member.displayHexColor, true) diff --git a/event/listeners/guildCreate.js b/event/listeners/guildCreate.js index d59de66b..76c2c974 100644 --- a/event/listeners/guildCreate.js +++ b/event/listeners/guildCreate.js @@ -1,5 +1,4 @@ const { Listener } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const { statsChannel } = require('../../config.json'); @@ -14,7 +13,7 @@ class guildCreateListener extends Listener { async exec(guild) { console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); const channel = this.client.channels.get(statsChannel); - const addEmbed = new MessageEmbed() + const addEmbed = this.client.util.embed() .setColor('#52e80d') .setTitle('New boiz in town') .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') diff --git a/event/listeners/guildDelete.js b/event/listeners/guildDelete.js index b787b9d0..c3397ef1 100644 --- a/event/listeners/guildDelete.js +++ b/event/listeners/guildDelete.js @@ -1,5 +1,4 @@ const { Listener } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const { statsChannel } = require('../../config.json'); @@ -15,7 +14,7 @@ class guildCreateListener extends Listener { console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`); const channel = this.client.channels.get(statsChannel); - const kickEmbed = new MessageEmbed() + const kickEmbed = this.client.util.embed() .setColor('#FF0000') .setTitle('Some mofo just removed me from there guild :(') .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') diff --git a/event/listeners/message.js b/event/listeners/message.js index a90c8137..2f3e20a5 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -1,5 +1,4 @@ const { Listener } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const rand = require('../../rand.js'); const Sequelize = require('sequelize'); const Tag = require('../../models').Tag; @@ -33,7 +32,7 @@ class messageListener extends Listener { let regex = new RegExp(bannedWords[i].get('word'), 'g'); censoredMessage = censoredMessage.replace(regex, '█'.repeat(bannedWords[i].get('word').length)); } - let Embed = new MessageEmbed() + let Embed = this.client.util.embed() .setColor(message.member.displayHexColor) .setAuthor(message.author.username, message.author.displayAvatarURL()) .setDescription(censoredMessage); @@ -183,7 +182,7 @@ class messageListener extends Listener { } } - const embed = new MessageEmbed() + const embed = this.client.util.embed() .setColor(color) .setTitle(title) .setImage(image) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 030ac7f2..e68b8cf0 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -1,5 +1,4 @@ const { Listener } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); const fs = require('fs'); let messageID = require('../../json/starboard.json'); @@ -59,7 +58,7 @@ class MessageReactionAddListener extends Listener { channel = client.channels.get(shameboardChannel['shameboard']); } - let Embed = new MessageEmbed() + let Embed = this.client.util.embed() .setColor(reaction.message.member.displayHexColor) .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL()) .addField('Jump to', `[message](https://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id})`, true)