From 89fce733d6ca0bd1dfa89974cbc8bc9a255d0062 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 25 Feb 2020 09:24:45 -0500 Subject: [PATCH] New Embed Builder in d.js master is garbo --- commands/events/apod.js | 2 +- commands/events/doomsday-clock.js | 2 +- commands/events/horoscope.js | 2 +- commands/events/today-in-history.js | 2 +- commands/info/avatar.js | 2 +- commands/info/channel.js | 2 +- commands/info/emoji.js | 2 +- commands/info/first-message.js | 2 +- commands/info/message.js | 2 +- commands/info/role.js | 2 +- commands/info/server.js | 2 +- commands/info/user.js | 2 +- commands/random/meme.js | 2 +- commands/random/subreddit.js | 2 +- commands/random/waifu.js | 2 +- commands/search/anime.js | 2 +- commands/search/book.js | 2 +- commands/search/bulbapedia.js | 2 +- commands/search/character.js | 2 +- commands/search/github.js | 2 +- commands/search/itunes.js | 2 +- commands/search/kickstarter.js | 2 +- commands/search/know-your-meme.js | 2 +- commands/search/league-of-legends.js | 2 +- commands/search/manga.js | 2 +- commands/search/mayo-clinic.js | 2 +- commands/search/mdn.js | 2 +- commands/search/movie.js | 2 +- commands/search/nasa.js | 2 +- commands/search/neopets-item.js | 2 +- commands/search/npm.js | 2 +- commands/search/osu.js | 2 +- commands/search/pokedex.js | 2 +- commands/search/recipe.js | 2 +- commands/search/reddit.js | 2 +- commands/search/rotten-tomatoes.js | 2 +- commands/search/soundcloud.js | 2 +- commands/search/stack-overflow.js | 2 +- commands/search/steam.js | 2 +- commands/search/stocks.js | 2 +- commands/search/tumblr.js | 2 +- commands/search/tv-show.js | 2 +- commands/search/twitter.js | 2 +- commands/search/urban.js | 2 +- commands/search/vocadb.js | 2 +- commands/search/wattpad.js | 2 +- commands/search/weather.js | 2 +- commands/search/wikia.js | 2 +- commands/search/wikipedia.js | 2 +- commands/search/xkcd.js | 2 +- commands/search/youtube.js | 2 +- commands/search/yu-gi-oh.js | 2 +- commands/sp-games/google-feud.js | 2 +- commands/text-edit/embed.js | 2 +- commands/text-edit/translate.js | 2 +- commands/util/changelog.js | 2 +- commands/util/credit.js | 2 +- commands/util/help.js | 2 +- commands/util/info.js | 2 +- structures/MessageEmbed.js | 386 +++++++++++++++++++++++++++ 60 files changed, 445 insertions(+), 59 deletions(-) create mode 100644 structures/MessageEmbed.js diff --git a/commands/events/apod.js b/commands/events/apod.js index 6bcc6864..1d5f3f1e 100644 --- a/commands/events/apod.js +++ b/commands/events/apod.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { shorten } = require('../../util/Util'); const { GOV_KEY } = process.env; diff --git a/commands/events/doomsday-clock.js b/commands/events/doomsday-clock.js index 6ef5ae66..7f33b5f2 100644 --- a/commands/events/doomsday-clock.js +++ b/commands/events/doomsday-clock.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class DoomsdayClockCommand extends Command { constructor(client) { diff --git a/commands/events/horoscope.js b/commands/events/horoscope.js index 80d2d7a7..ef6d3bc6 100644 --- a/commands/events/horoscope.js +++ b/commands/events/horoscope.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const cheerio = require('cheerio'); const { list, firstUpperCase } = require('../../util/Util'); diff --git a/commands/events/today-in-history.js b/commands/events/today-in-history.js index b6f31c60..db7f9aa4 100644 --- a/commands/events/today-in-history.js +++ b/commands/events/today-in-history.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); module.exports = class TodayInHistoryCommand extends Command { diff --git a/commands/info/avatar.js b/commands/info/avatar.js index 7713aff1..999c0216 100644 --- a/commands/info/avatar.js +++ b/commands/info/avatar.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class AvatarCommand extends Command { constructor(client) { diff --git a/commands/info/channel.js b/commands/info/channel.js index 177723b9..7b471a60 100644 --- a/commands/info/channel.js +++ b/commands/info/channel.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const types = { dm: 'DM', group: 'Group DM', diff --git a/commands/info/emoji.js b/commands/info/emoji.js index f3eaf02e..6280f815 100644 --- a/commands/info/emoji.js +++ b/commands/info/emoji.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class EmojiCommand extends Command { constructor(client) { diff --git a/commands/info/first-message.js b/commands/info/first-message.js index 1672550f..5f6cd1d3 100644 --- a/commands/info/first-message.js +++ b/commands/info/first-message.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class FirstMessageCommand extends Command { constructor(client) { diff --git a/commands/info/message.js b/commands/info/message.js index db5de698..4a26b177 100644 --- a/commands/info/message.js +++ b/commands/info/message.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class MessageCommand extends Command { constructor(client) { diff --git a/commands/info/role.js b/commands/info/role.js index cc9584f2..5fe22edd 100644 --- a/commands/info/role.js +++ b/commands/info/role.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { util: { permissions } } = require('discord.js-commando'); module.exports = class RoleCommand extends Command { diff --git a/commands/info/server.js b/commands/info/server.js index 8fa8701d..4dd3eb48 100644 --- a/commands/info/server.js +++ b/commands/info/server.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { stripIndents } = require('common-tags'); const filterLevels = ['Off', 'No Role', 'Everyone']; const verificationLevels = ['None', 'Low', 'Medium', '(╯°□°)╯︵ ┻━┻', '┻━┻ ミヽ(ಠ益ಠ)ノ彡┻━┻']; diff --git a/commands/info/user.js b/commands/info/user.js index edd1d567..74782f27 100644 --- a/commands/info/user.js +++ b/commands/info/user.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { stripIndents } = require('common-tags'); const { trimArray } = require('../../util/Util'); diff --git a/commands/random/meme.js b/commands/random/meme.js index 7d3438ec..f6472be6 100644 --- a/commands/random/meme.js +++ b/commands/random/meme.js @@ -1,5 +1,5 @@ const SubredditCommand = require('../../structures/commands/Subreddit'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { list, formatNumber } = require('../../util/Util'); const subreddits = require('../../assets/json/meme'); diff --git a/commands/random/subreddit.js b/commands/random/subreddit.js index 55bbc6c4..00041e2c 100644 --- a/commands/random/subreddit.js +++ b/commands/random/subreddit.js @@ -1,5 +1,5 @@ const SubredditCommandBase = require('../../structures/commands/Subreddit'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { formatNumber } = require('../../util/Util'); module.exports = class SubredditCommand extends SubredditCommandBase { diff --git a/commands/random/waifu.js b/commands/random/waifu.js index cd15d5d2..1379450e 100644 --- a/commands/random/waifu.js +++ b/commands/random/waifu.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/anime.js b/commands/search/anime.js index c26f5cfa..eb222001 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { cleanAnilistHTML } = require('../../util/Util'); diff --git a/commands/search/book.js b/commands/search/book.js index 963e8d9d..61413841 100644 --- a/commands/search/book.js +++ b/commands/search/book.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); const { GOOGLE_KEY } = process.env; diff --git a/commands/search/bulbapedia.js b/commands/search/bulbapedia.js index 90c32f56..6a198c59 100644 --- a/commands/search/bulbapedia.js +++ b/commands/search/bulbapedia.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/character.js b/commands/search/character.js index 78c21122..8da8a2b3 100644 --- a/commands/search/character.js +++ b/commands/search/character.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { cleanAnilistHTML } = require('../../util/Util'); diff --git a/commands/search/github.js b/commands/search/github.js index 9ab9c5b3..be75b5c5 100644 --- a/commands/search/github.js +++ b/commands/search/github.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber, base64 } = require('../../util/Util'); const { GITHUB_USERNAME, GITHUB_PASSWORD } = process.env; diff --git a/commands/search/itunes.js b/commands/search/itunes.js index ce20fb97..bd1f6dbc 100644 --- a/commands/search/itunes.js +++ b/commands/search/itunes.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); module.exports = class ItunesCommand extends Command { diff --git a/commands/search/kickstarter.js b/commands/search/kickstarter.js index 36755ddd..36b069bb 100644 --- a/commands/search/kickstarter.js +++ b/commands/search/kickstarter.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); diff --git a/commands/search/know-your-meme.js b/commands/search/know-your-meme.js index df48072e..aa6fe302 100644 --- a/commands/search/know-your-meme.js +++ b/commands/search/know-your-meme.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); const cheerio = require('cheerio'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { shorten } = require('../../util/Util'); module.exports = class KnowYourMemeCommand extends Command { diff --git a/commands/search/league-of-legends.js b/commands/search/league-of-legends.js index 092fd9c0..525474c2 100644 --- a/commands/search/league-of-legends.js +++ b/commands/search/league-of-legends.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const buttons = ['Q', 'W', 'E', 'R']; diff --git a/commands/search/manga.js b/commands/search/manga.js index f5b913a5..ebd7b365 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { cleanAnilistHTML } = require('../../util/Util'); diff --git a/commands/search/mayo-clinic.js b/commands/search/mayo-clinic.js index 5bce5b25..be409517 100644 --- a/commands/search/mayo-clinic.js +++ b/commands/search/mayo-clinic.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); const cheerio = require('cheerio'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { shorten } = require('../../util/Util'); module.exports = class MayoClinicCommand extends Command { diff --git a/commands/search/mdn.js b/commands/search/mdn.js index 7d3efc51..5c63fe18 100644 --- a/commands/search/mdn.js +++ b/commands/search/mdn.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); module.exports = class MDNCommand extends Command { diff --git a/commands/search/movie.js b/commands/search/movie.js index f4aee8ed..9cc79a84 100644 --- a/commands/search/movie.js +++ b/commands/search/movie.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); const { TMDB_KEY } = process.env; diff --git a/commands/search/nasa.js b/commands/search/nasa.js index cea99a35..216ab9db 100644 --- a/commands/search/nasa.js +++ b/commands/search/nasa.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { shorten } = require('../../util/Util'); module.exports = class NASACommand extends Command { diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js index a4802464..274a473f 100644 --- a/commands/search/neopets-item.js +++ b/commands/search/neopets-item.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { formatNumber } = require('../../util/Util'); module.exports = class NeopetsItemCommand extends Command { diff --git a/commands/search/npm.js b/commands/search/npm.js index 7bd36796..de8fa6f2 100644 --- a/commands/search/npm.js +++ b/commands/search/npm.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { trimArray } = require('../../util/Util'); diff --git a/commands/search/osu.js b/commands/search/osu.js index b07a15d8..d1318f35 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber } = require('../../util/Util'); const { OSU_KEY } = process.env; diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index 1d24b206..a07857e7 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { stripIndents } = require('common-tags'); module.exports = class PokedexCommand extends Command { diff --git a/commands/search/recipe.js b/commands/search/recipe.js index 6e2dc9ed..6f975b68 100644 --- a/commands/search/recipe.js +++ b/commands/search/recipe.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); module.exports = class RecipeCommand extends Command { diff --git a/commands/search/reddit.js b/commands/search/reddit.js index 19669942..25563569 100644 --- a/commands/search/reddit.js +++ b/commands/search/reddit.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const moment = require('moment'); const { formatNumber } = require('../../util/Util'); diff --git a/commands/search/rotten-tomatoes.js b/commands/search/rotten-tomatoes.js index aa23ac47..acb09536 100644 --- a/commands/search/rotten-tomatoes.js +++ b/commands/search/rotten-tomatoes.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index e274ce20..d98f01f7 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); const { SOUNDCLOUD_KEY } = process.env; diff --git a/commands/search/stack-overflow.js b/commands/search/stack-overflow.js index 21ef4ced..d19dcb1c 100644 --- a/commands/search/stack-overflow.js +++ b/commands/search/stack-overflow.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber } = require('../../util/Util'); const { STACKOVERFLOW_KEY } = process.env; diff --git a/commands/search/steam.js b/commands/search/steam.js index 375078e9..218f751a 100644 --- a/commands/search/steam.js +++ b/commands/search/steam.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber } = require('../../util/Util'); diff --git a/commands/search/stocks.js b/commands/search/stocks.js index ff7dfb6d..09fcf5b4 100644 --- a/commands/search/stocks.js +++ b/commands/search/stocks.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber } = require('../../util/Util'); const { ALPHA_VANTAGE_KEY } = process.env; diff --git a/commands/search/tumblr.js b/commands/search/tumblr.js index 24f021c7..09f161a4 100644 --- a/commands/search/tumblr.js +++ b/commands/search/tumblr.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber } = require('../../util/Util'); const { TUMBLR_KEY } = process.env; diff --git a/commands/search/tv-show.js b/commands/search/tv-show.js index 69a7caf0..555a9d8f 100644 --- a/commands/search/tv-show.js +++ b/commands/search/tv-show.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); const { TMDB_KEY } = process.env; diff --git a/commands/search/twitter.js b/commands/search/twitter.js index 0a4f62f3..a2025b8f 100644 --- a/commands/search/twitter.js +++ b/commands/search/twitter.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { formatNumber, base64 } = require('../../util/Util'); const { TWITTER_KEY, TWITTER_SECRET } = process.env; diff --git a/commands/search/urban.js b/commands/search/urban.js index 72986f62..c09ff535 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); diff --git a/commands/search/vocadb.js b/commands/search/vocadb.js index 3153e81e..4b92e84c 100644 --- a/commands/search/vocadb.js +++ b/commands/search/vocadb.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index c59aa5ec..4b8e4436 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); const { WATTPAD_KEY } = process.env; diff --git a/commands/search/weather.js b/commands/search/weather.js index 1cdffd31..4f56feb5 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { OPENWEATHERMAP_KEY } = process.env; diff --git a/commands/search/wikia.js b/commands/search/wikia.js index ce3e72bf..a94896f9 100644 --- a/commands/search/wikia.js +++ b/commands/search/wikia.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 92ccc68a..3875a48d 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); diff --git a/commands/search/xkcd.js b/commands/search/xkcd.js index a947a2f3..1186b207 100644 --- a/commands/search/xkcd.js +++ b/commands/search/xkcd.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const types = ['random', 'today']; diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 7538f350..74ece209 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { GOOGLE_KEY } = process.env; diff --git a/commands/search/yu-gi-oh.js b/commands/search/yu-gi-oh.js index 83fdb52b..013cec90 100644 --- a/commands/search/yu-gi-oh.js +++ b/commands/search/yu-gi-oh.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); diff --git a/commands/sp-games/google-feud.js b/commands/sp-games/google-feud.js index 709b9ecd..8f022672 100644 --- a/commands/sp-games/google-feud.js +++ b/commands/sp-games/google-feud.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const questions = require('../../assets/json/google-feud'); module.exports = class GoogleFeudCommand extends Command { diff --git a/commands/text-edit/embed.js b/commands/text-edit/embed.js index 9a555287..296a436c 100644 --- a/commands/text-edit/embed.js +++ b/commands/text-edit/embed.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class EmbedCommand extends Command { constructor(client) { diff --git a/commands/text-edit/translate.js b/commands/text-edit/translate.js index c9eae66b..2d4b60c2 100644 --- a/commands/text-edit/translate.js +++ b/commands/text-edit/translate.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const translate = require('@vitalets/google-translate-api'); const { list } = require('../../util/Util'); const codes = translate.languages; diff --git a/commands/util/changelog.js b/commands/util/changelog.js index aa56f544..03f0fe20 100644 --- a/commands/util/changelog.js +++ b/commands/util/changelog.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const request = require('node-superfetch'); const { shorten, base64 } = require('../../util/Util'); const { GITHUB_USERNAME, GITHUB_PASSWORD, XIAO_GITHUB_REPO_USERNAME, XIAO_GITHUB_REPO_NAME } = process.env; diff --git a/commands/util/credit.js b/commands/util/credit.js index 96bf28a1..238369d5 100644 --- a/commands/util/credit.js +++ b/commands/util/credit.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); module.exports = class CreditCommand extends Command { constructor(client) { diff --git a/commands/util/help.js b/commands/util/help.js index 4873a41e..ee611903 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const { stripIndents } = require('common-tags'); module.exports = class HelpCommand extends Command { diff --git a/commands/util/info.js b/commands/util/info.js index 3c9da840..214f464c 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); +const MessageEmbed = require('../../structures/MessageEmbed'); const moment = require('moment'); require('moment-duration-format'); const { formatNumber } = require('../../util/Util'); diff --git a/structures/MessageEmbed.js b/structures/MessageEmbed.js new file mode 100644 index 00000000..dda78d7a --- /dev/null +++ b/structures/MessageEmbed.js @@ -0,0 +1,386 @@ +'use strict'; + +// Credit: https://github.com/discordjs/discord.js/blob/ecd8cccddf9b83f4f7cd858fdcad9e436ac51794/src/structures/MessageEmbed.js + +const { Util } = require('discord.js'); + +/** + * Represents an embed in a message (image/video preview, rich embed, etc.) + */ +class MessageEmbed { + constructor(data = {}) { + this.setup(data); + } + + setup(data) { // eslint-disable-line complexity + /** + * The type of this embed, either: + * * `image` - an image embed + * * `video` - a video embed + * * `gifv` - a gifv embed + * * `link` - a link embed + * * `rich` - a rich embed + * @type {string} + */ + this.type = data.type; + + /** + * The title of this embed + * @type {?string} + */ + this.title = data.title; + + /** + * The description of this embed + * @type {?string} + */ + this.description = data.description; + + /** + * The URL of this embed + * @type {?string} + */ + this.url = data.url; + + /** + * The color of this embed + * @type {?number} + */ + this.color = Util.resolveColor(data.color); + + /** + * The timestamp of this embed + * @type {?number} + */ + this.timestamp = data.timestamp ? new Date(data.timestamp).getTime() : null; + + /** + * @typedef {Object} EmbedField + * @property {string} name The name of this field + * @property {string} value The value of this field + * @property {boolean} inline If this field will be displayed inline + */ + + /** + * The fields of this embed + * @type {EmbedField[]} + */ + this.fields = data.fields ? data.fields.map(Util.cloneObject) : []; + + /** + * The thumbnail of this embed (if there is one) + * @type {?Object} + * @property {string} url URL for this thumbnail + * @property {string} proxyURL ProxyURL for this thumbnail + * @property {number} height Height of this thumbnail + * @property {number} width Width of this thumbnail + */ + this.thumbnail = data.thumbnail ? { + url: data.thumbnail.url, + proxyURL: data.thumbnail.proxy_url, + height: data.thumbnail.height, + width: data.thumbnail.width, + } : null; + + /** + * The image of this embed, if there is one + * @type {?Object} + * @property {string} url URL for this image + * @property {string} proxyURL ProxyURL for this image + * @property {number} height Height of this image + * @property {number} width Width of this image + */ + this.image = data.image ? { + url: data.image.url, + proxyURL: data.image.proxy_url, + height: data.image.height, + width: data.image.width, + } : null; + + /** + * The video of this embed (if there is one) + * @type {?Object} + * @property {string} url URL of this video + * @property {string} proxyURL ProxyURL for this video + * @property {number} height Height of this video + * @property {number} width Width of this video + * @readonly + */ + this.video = data.video ? { + url: data.video.url, + proxyURL: data.video.proxy_url, + height: data.video.height, + width: data.video.width, + } : null; + + /** + * The author of this embed (if there is one) + * @type {?Object} + * @property {string} name The name of this author + * @property {string} url URL of this author + * @property {string} iconURL URL of the icon for this author + * @property {string} proxyIconURL Proxied URL of the icon for this author + */ + this.author = data.author ? { + name: data.author.name, + url: data.author.url, + iconURL: data.author.iconURL || data.author.icon_url, + proxyIconURL: data.author.proxyIconUrl || data.author.proxy_icon_url, + } : null; + + /** + * The provider of this embed (if there is one) + * @type {?Object} + * @property {string} name The name of this provider + * @property {string} url URL of this provider + */ + this.provider = data.provider; + + /** + * The footer of this embed + * @type {?Object} + * @property {string} text The text of this footer + * @property {string} iconURL URL of the icon for this footer + * @property {string} proxyIconURL Proxied URL of the icon for this footer + */ + this.footer = data.footer ? { + text: data.footer.text, + iconURL: data.footer.iconURL || data.footer.icon_url, + proxyIconURL: data.footer.proxyIconURL || data.footer.proxy_icon_url, + } : null; + + /** + * The files of this embed + * @type {Array} + */ + this.files = data.files || []; + } + + /** + * The date this embed was created at + * @type {?Date} + * @readonly + */ + get createdAt() { + return this.timestamp ? new Date(this.timestamp) : null; + } + + /** + * The hexadecimal version of the embed color, with a leading hash + * @type {?string} + * @readonly + */ + get hexColor() { + return this.color ? `#${this.color.toString(16).padStart(6, '0')}` : null; + } + + /** + * The accumulated length for the embed title, description, fields and footer text + * @type {number} + * @readonly + */ + get length() { + return ( + (this.title ? this.title.length : 0) + + (this.description ? this.description.length : 0) + + (this.fields.length >= 1 ? this.fields.reduce((prev, curr) => + prev + curr.name.length + curr.value.length, 0) : 0) + + (this.footer ? this.footer.text.length : 0)); + } + + /** + * Adds a field to the embed (max 25). + * @param {StringResolvable} name The name of the field + * @param {StringResolvable} value The value of the field + * @param {boolean} [inline=false] Set the field to display inline + * @returns {MessageEmbed} + */ + addField(name, value, inline) { + this.fields.push(this.constructor.checkField(name, value, inline)); + return this; + } + + /** + * Convenience function for `.addField('\u200B', '\u200B', inline)`. + * @param {boolean} [inline=false] Set the field to display inline + * @returns {MessageEmbed} + */ + addBlankField(inline) { + return this.addField('\u200B', '\u200B', inline); + } + + /** + * Removes, replaces, and inserts fields in the embed (max 25). + * @param {number} index The index to start at + * @param {number} deleteCount The number of fields to remove + * @param {StringResolvable} [name] The name of the field + * @param {StringResolvable} [value] The value of the field + * @param {boolean} [inline=false] Set the field to display inline + * @returns {MessageEmbed} + */ + spliceField(index, deleteCount, name, value, inline) { + if (name && value) { + this.fields.splice(index, deleteCount, this.constructor.checkField(name, value, inline)); + } else { + this.fields.splice(index, deleteCount); + } + return this; + } + + /** + * Sets the file to upload alongside the embed. This file can be accessed via `attachment://fileName.extension` when + * setting an embed image or author/footer icons. Multiple files can be attached. + * @param {Array} files Files to attach + * @returns {MessageEmbed} + */ + attachFiles(files) { + this.files = this.files.concat(files); + return this; + } + + /** + * Sets the author of this embed. + * @param {StringResolvable} name The name of the author + * @param {string} [iconURL] The icon URL of the author + * @param {string} [url] The URL of the author + * @returns {MessageEmbed} + */ + setAuthor(name, iconURL, url) { + this.author = { name: Util.resolveString(name), iconURL, url }; + return this; + } + + /** + * Sets the color of this embed. + * @param {ColorResolvable} color The color of the embed + * @returns {MessageEmbed} + */ + setColor(color) { + this.color = Util.resolveColor(color); + return this; + } + + /** + * Sets the description of this embed. + * @param {StringResolvable} description The description + * @returns {MessageEmbed} + */ + setDescription(description) { + description = Util.resolveString(description); + this.description = description; + return this; + } + + /** + * Sets the footer of this embed. + * @param {StringResolvable} text The text of the footer + * @param {string} [iconURL] The icon URL of the footer + * @returns {MessageEmbed} + */ + setFooter(text, iconURL) { + text = Util.resolveString(text); + this.footer = { text, iconURL }; + return this; + } + + /** + * Sets the image of this embed. + * @param {string} url The URL of the image + * @returns {MessageEmbed} + */ + setImage(url) { + this.image = { url }; + return this; + } + + /** + * Sets the thumbnail of this embed. + * @param {string} url The URL of the thumbnail + * @returns {MessageEmbed} + */ + setThumbnail(url) { + this.thumbnail = { url }; + return this; + } + + /** + * Sets the timestamp of this embed. + * @param {Date|number} [timestamp=Date.now()] The timestamp or date + * @returns {MessageEmbed} + */ + setTimestamp(timestamp = Date.now()) { + if (timestamp instanceof Date) timestamp = timestamp.getTime(); + this.timestamp = timestamp; + return this; + } + + /** + * Sets the title of this embed. + * @param {StringResolvable} title The title + * @returns {MessageEmbed} + */ + setTitle(title) { + title = Util.resolveString(title); + this.title = title; + return this; + } + + /** + * Sets the URL of this embed. + * @param {string} url The URL + * @returns {MessageEmbed} + */ + setURL(url) { + this.url = url; + return this; + } + + toJSON() { + return Util.flatten(this, { hexColor: true }); + } + + /** + * Transforms the embed object to be processed. + * @returns {Object} The raw data of this embed + * @private + */ + _apiTransform() { + return { + title: this.title, + type: 'rich', + description: this.description, + url: this.url, + timestamp: this.timestamp ? new Date(this.timestamp) : null, + color: this.color, + fields: this.fields, + thumbnail: this.thumbnail, + image: this.image, + author: this.author ? { + name: this.author.name, + url: this.author.url, + icon_url: this.author.iconURL, + } : null, + footer: this.footer ? { + text: this.footer.text, + icon_url: this.footer.iconURL, + } : null, + }; + } + + /** + * Checks for valid field input and resolves strings + * @param {StringResolvable} name The name of the field + * @param {StringResolvable} value The value of the field + * @param {boolean} [inline=false] Set the field to display inline + * @returns {EmbedField} + */ + static checkField(name, value, inline = false) { + name = Util.resolveString(name); + if (!name) throw new Error('MessageEmbed field names may not be empty.'); + value = Util.resolveString(value); + if (!value) throw new Error('MessageEmbed field values may not be empty.'); + return { name, value, inline }; + } +} + +module.exports = MessageEmbed;