From ec38daefa35d5ee4a5d66c6a102bd3561f6a3e62 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 30 Mar 2024 13:13:01 -0400 Subject: [PATCH] Use JSON for logos --- assets/json/logos.json | 14 ++++++++++++++ commands/code/github.js | 3 ++- commands/code/lint-rule.js | 3 ++- commands/code/npm.js | 3 ++- commands/edit-text/translate.js | 3 ++- commands/events/apod.js | 7 ++----- commands/games-sp/anime-score.js | 3 ++- commands/search/anime-character.js | 3 ++- commands/search/anime-staff.js | 3 ++- commands/search/anime.js | 3 ++- commands/search/know-your-meme.js | 3 ++- commands/search/manga.js | 3 ++- commands/search/nasa.js | 3 ++- commands/search/neopets-item.js | 3 ++- commands/search/urban.js | 3 ++- commands/search/wikipedia.js | 3 ++- commands/search/yu-gi-oh.js | 3 ++- commands/voice/play.js | 3 ++- 18 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 assets/json/logos.json diff --git a/assets/json/logos.json b/assets/json/logos.json new file mode 100644 index 00000000..126072d7 --- /dev/null +++ b/assets/json/logos.json @@ -0,0 +1,14 @@ +{ + "github": "https://i.imgur.com/e4HunUm.png", + "eslint": "https://i.imgur.com/04GhEhU.png", + "npm": "https://i.imgur.com/ErKf5Y0.png", + "googleTranslate": "https://i.imgur.com/h3RoHyp.png", + "nasa": "https://i.imgur.com/Wh8jY9c.png", + "anilist": "https://i.imgur.com/iUIRC7v.png", + "kym": "https://i.imgur.com/WvcH4Z2.png", + "neopets": "https://i.imgur.com/BP8qxJH.png", + "urban": "https://i.imgur.com/Fo0nRTe.png", + "wikipedia": "https://i.imgur.com/Z7NJBK2.png", + "yugioh": "https://i.imgur.com/AJNBflD.png", + "youtube": "https://i.imgur.com/kKHJg9Q.png" +} diff --git a/commands/code/github.js b/commands/code/github.js index 12ca8348..0feb419e 100644 --- a/commands/code/github.js +++ b/commands/code/github.js @@ -3,6 +3,7 @@ const moment = require('moment'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const { GITHUB_ACCESS_TOKEN } = process.env; module.exports = class GithubCommand extends Command { @@ -44,7 +45,7 @@ module.exports = class GithubCommand extends Command { .set({ Authorization: `token ${GITHUB_ACCESS_TOKEN}` }); const embed = new MessageEmbed() .setColor(0xFFFFFF) - .setAuthor('GitHub', 'https://i.imgur.com/e4HunUm.png', 'https://github.com/') + .setAuthor('GitHub', logos.github, 'https://github.com/') .setTitle(body.full_name) .setURL(body.html_url) .setDescription(body.description ? shorten(body.description) : 'No description.') diff --git a/commands/code/lint-rule.js b/commands/code/lint-rule.js index f5c118ae..8fe55924 100644 --- a/commands/code/lint-rule.js +++ b/commands/code/lint-rule.js @@ -1,5 +1,6 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); +const logos = require('../../assets/json/logos'); const { Linter } = require('eslint'); const linter = new Linter(); const rules = linter.getRules(); @@ -27,7 +28,7 @@ module.exports = class LintRuleCommand extends Command { if (!rules.has(rule)) return msg.say('Could not find any results.'); const data = rules.get(rule).meta; const embed = new MessageEmbed() - .setAuthor('ESLint', 'https://i.imgur.com/04GhEhU.png', 'https://eslint.org/') + .setAuthor('ESLint', logos.eslint, 'https://eslint.org/') .setColor(0x3A33D1) .setTitle(rule) .setURL(data.docs.url) diff --git a/commands/code/npm.js b/commands/code/npm.js index 95aa9327..2fe67b16 100644 --- a/commands/code/npm.js +++ b/commands/code/npm.js @@ -3,6 +3,7 @@ const moment = require('moment'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { trimArray } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class NPMCommand extends Command { constructor(client) { @@ -39,7 +40,7 @@ module.exports = class NPMCommand extends Command { const dependencies = version.dependencies ? trimArray(Object.keys(version.dependencies)) : null; const embed = new MessageEmbed() .setColor(0xCB0000) - .setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png', 'https://www.npmjs.com/') + .setAuthor('NPM', logos.npm, 'https://www.npmjs.com/') .setTitle(body.name) .setURL(`https://www.npmjs.com/package/${pkg}`) .setDescription(body.description || 'No description.') diff --git a/commands/edit-text/translate.js b/commands/edit-text/translate.js index 754ab180..85123a2d 100644 --- a/commands/edit-text/translate.js +++ b/commands/edit-text/translate.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); const translate = require('@vitalets/google-translate-api'); const { list } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const codes = Object.keys(translate.languages).filter(code => typeof translate.languages[code] !== 'function'); module.exports = class TranslateCommand extends Command { @@ -55,7 +56,7 @@ module.exports = class TranslateCommand extends Command { const { text: result, from } = await translate(text, { to: target, from: base }); const embed = new MessageEmbed() .setColor(0x4285F4) - .setFooter('Powered by Google Translate', 'https://i.imgur.com/h3RoHyp.png') + .setFooter('Powered by Google Translate', logos.googleTranslate) .addField(`❯ From: ${translate.languages[from.language.iso]}`, from.text.value || text) .addField(`❯ To: ${translate.languages[target]}`, result); return msg.embed(embed); diff --git a/commands/events/apod.js b/commands/events/apod.js index 7711e472..bf7f0854 100644 --- a/commands/events/apod.js +++ b/commands/events/apod.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); const { MessageEmbed } = require('discord.js'); const { shorten } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const { GOV_KEY } = process.env; module.exports = class ApodCommand extends Command { @@ -32,11 +33,7 @@ module.exports = class ApodCommand extends Command { .setTitle(body.title) .setDescription(shorten(body.explanation)) .setColor(0x2E528E) - .setAuthor( - 'Astronomy Picture of the Day', - 'https://i.imgur.com/Wh8jY9c.png', - 'https://apod.nasa.gov/apod/astropix.html' - ) + .setAuthor('Astronomy Picture of the Day', logos.nasa, 'https://apod.nasa.gov/apod/astropix.html') .setImage(body.media_type === 'image' ? body.url : null) .setURL(body.url) .setFooter(`Image Credits: ${body.copyright ? body.copyright.replaceAll('\n', '/') : 'Public Domain'}`) diff --git a/commands/games-sp/anime-score.js b/commands/games-sp/anime-score.js index b5075d99..8d894ae4 100644 --- a/commands/games-sp/anime-score.js +++ b/commands/games-sp/anime-score.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); +const logos = require('../../assets/json/logos'); const searchGraphQL = stripIndents` query ($page: Int, $type: MediaType, $isAdult: Boolean) { Page (page: $page) { @@ -60,7 +61,7 @@ module.exports = class AnimeScoreCommand extends Command { const anime = await this.getRandomAnime(msg.channel.nsfw); const embed = new MessageEmbed() .setColor(0x02A9FF) - .setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/') + .setAuthor('AniList', logos.anilist, 'https://anilist.co/') .setImage(anime.coverImage.large || anime.coverImage.medium || null) .setTitle(anime.title.english || anime.title.romaji) .setDescription(`_${anime.startDate.year}, ${formats[anime.format]}_`) diff --git a/commands/search/anime-character.js b/commands/search/anime-character.js index e33f3eb9..5b19da4a 100644 --- a/commands/search/anime-character.js +++ b/commands/search/anime-character.js @@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { embedURL, cleanAnilistHTML, trimArray } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const searchGraphQL = stripIndents` query ($search: String) { characters: Page (perPage: 1) { @@ -76,7 +77,7 @@ module.exports = class AnimeCharacterCommand extends Command { const character = await this.fetchCharacter(id); const embed = new MessageEmbed() .setColor(0x02A9FF) - .setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/') + .setAuthor('AniList', logos.anilist, 'https://anilist.co/') .setURL(character.siteUrl) .setThumbnail(character.image.large || character.image.medium || null) .setTitle(`${character.name.first || ''}${character.name.last ? ` ${character.name.last}` : ''}`) diff --git a/commands/search/anime-staff.js b/commands/search/anime-staff.js index 9ed2acdd..7b605db6 100644 --- a/commands/search/anime-staff.js +++ b/commands/search/anime-staff.js @@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { embedURL, cleanAnilistHTML, trimArray } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const searchGraphQL = stripIndents` query ($search: String) { staff: Page (perPage: 1) { @@ -96,7 +97,7 @@ module.exports = class AnimeStaffCommand extends Command { const staff = await this.fetchStaff(id); const embed = new MessageEmbed() .setColor(0x02A9FF) - .setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/') + .setAuthor('AniList', logos.anilist, 'https://anilist.co/') .setURL(staff.siteUrl) .setThumbnail(staff.image.large || staff.image.medium || null) .setTitle(`${staff.name.first || ''}${staff.name.last ? ` ${staff.name.last}` : ''}`) diff --git a/commands/search/anime.js b/commands/search/anime.js index 1ab5e5a3..8f772fc7 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -4,6 +4,7 @@ const request = require('node-superfetch'); const cheerio = require('cheerio'); const { stripIndents } = require('common-tags'); const { cleanAnilistHTML, embedURL } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535'; const searchGraphQL = stripIndents` query ($search: String, $type: MediaType, $isAdult: Boolean) { @@ -119,7 +120,7 @@ module.exports = class AnimeCommand extends Command { const malURL = `https://myanimelist.net/anime/${anime.idMal}`; const embed = new MessageEmbed() .setColor(0x02A9FF) - .setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/') + .setAuthor('AniList', logos.anilist, 'https://anilist.co/') .setURL(anime.siteUrl) .setThumbnail(anime.coverImage.large || anime.coverImage.medium || null) .setTitle(anime.title.english || anime.title.romaji) diff --git a/commands/search/know-your-meme.js b/commands/search/know-your-meme.js index 50c6366a..eb166947 100644 --- a/commands/search/know-your-meme.js +++ b/commands/search/know-your-meme.js @@ -3,6 +3,7 @@ const request = require('node-superfetch'); const cheerio = require('cheerio'); const { MessageEmbed } = require('discord.js'); const { shorten } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class KnowYourMemeCommand extends Command { constructor(client) { @@ -35,7 +36,7 @@ module.exports = class KnowYourMemeCommand extends Command { const data = await this.fetchMeme(location); const embed = new MessageEmbed() .setColor(0x12133F) - .setAuthor('Know Your Meme', 'https://i.imgur.com/WvcH4Z2.png', 'https://knowyourmeme.com/') + .setAuthor('Know Your Meme', logos.kym, 'https://knowyourmeme.com/') .setTitle(data.name) .setDescription(shorten(data.description || 'No description available.')) .setURL(data.url) diff --git a/commands/search/manga.js b/commands/search/manga.js index 7d17214e..07d3c392 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -4,6 +4,7 @@ const request = require('node-superfetch'); const cheerio = require('cheerio'); const { stripIndents } = require('common-tags'); const { cleanAnilistHTML, embedURL } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535'; const searchGraphQL = stripIndents` query ($search: String, $type: MediaType, $isAdult: Boolean) { @@ -112,7 +113,7 @@ module.exports = class MangaCommand extends Command { const malURL = `https://myanimelist.net/manga/${manga.idMal}`; const embed = new MessageEmbed() .setColor(0x02A9FF) - .setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/') + .setAuthor('AniList', logos.anilist, 'https://anilist.co/') .setURL(manga.siteUrl) .setThumbnail(manga.coverImage.large || manga.coverImage.medium || null) .setTitle(manga.title.english || manga.title.romaji) diff --git a/commands/search/nasa.js b/commands/search/nasa.js index 6e9b5b02..3460f4cc 100644 --- a/commands/search/nasa.js +++ b/commands/search/nasa.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); const { MessageEmbed } = require('discord.js'); const { shorten, embedURL } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class NASACommand extends Command { constructor(client) { @@ -42,7 +43,7 @@ module.exports = class NASACommand extends Command { .setTitle(shorten(data.data[0].title, 256)) .setDescription(shorten(this.cleanHTML(data.data[0].description))) .setColor(0x2E528E) - .setAuthor('NASA', 'https://i.imgur.com/Wh8jY9c.png', 'https://www.nasa.gov/multimedia/imagegallery/index.html') + .setAuthor('NASA', logos.nasa, 'https://www.nasa.gov/multimedia/imagegallery/index.html') .setImage(`https://images-assets.nasa.gov/image/${data.data[0].nasa_id}/${data.data[0].nasa_id}~thumb.jpg`) .setFooter(`Image Credits: ${data.data[0].center || 'Public Domain'}`) .setTimestamp(new Date(data.data[0].date_created)); diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js index 7606ecd0..7efbda69 100644 --- a/commands/search/neopets-item.js +++ b/commands/search/neopets-item.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); const { MessageEmbed } = require('discord.js'); const { formatNumber } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class NeopetsItemCommand extends Command { constructor(client) { @@ -38,7 +39,7 @@ module.exports = class NeopetsItemCommand extends Command { if (!data) return msg.say('Could not find any results.'); const embed = new MessageEmbed() .setColor(0xFFCE31) - .setAuthor('Neopets', 'https://i.imgur.com/BP8qxJH.png', 'http://www.neopets.com/') + .setAuthor('Neopets', logos.neopets, 'http://www.neopets.com/') .setTitle(data.name) .setDescription(data.details) .setURL(data.url) diff --git a/commands/search/urban.js b/commands/search/urban.js index c9867d17..b48c7e59 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class UrbanCommand extends Command { constructor(client) { @@ -37,7 +38,7 @@ module.exports = class UrbanCommand extends Command { const data = body.list[0]; const embed = new MessageEmbed() .setColor(0x32A8F0) - .setAuthor('Urban Dictionary', 'https://i.imgur.com/Fo0nRTe.png', 'https://www.urbandictionary.com/') + .setAuthor('Urban Dictionary', logos.urban, 'https://www.urbandictionary.com/') .setURL(data.permalink) .setTitle(data.word) .setDescription(shorten(data.definition.replace(/\[|\]/g, ''))) diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index c06ea6f2..ec07d294 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { shorten } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class WikipediaCommand extends Command { constructor(client) { @@ -46,7 +47,7 @@ module.exports = class WikipediaCommand extends Command { const embed = new MessageEmbed() .setColor(0xE7E7E7) .setTitle(data.title) - .setAuthor('Wikipedia', 'https://i.imgur.com/Z7NJBK2.png', 'https://www.wikipedia.org/') + .setAuthor('Wikipedia', logos.wikipedia, 'https://www.wikipedia.org/') .setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query).replaceAll(')', '%29')}`) .setDescription(shorten(data.extract.replaceAll('\n', '\n\n'))); return msg.embed(embed); diff --git a/commands/search/yu-gi-oh.js b/commands/search/yu-gi-oh.js index 17213583..d2b13482 100644 --- a/commands/search/yu-gi-oh.js +++ b/commands/search/yu-gi-oh.js @@ -2,6 +2,7 @@ const Command = require('../../framework/Command'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const { shorten, formatNumber } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); module.exports = class YuGiOhCommand extends Command { constructor(client) { @@ -48,7 +49,7 @@ module.exports = class YuGiOhCommand extends Command { .setTitle(data.name) .setURL(`https://db.ygoprodeck.com/card/?search=${data.id}`) .setDescription(data.type === 'Normal Monster' ? `_${shorten(data.desc)}_` : shorten(data.desc)) - .setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png', 'http://www.yugioh-card.com/') + .setAuthor('Yu-Gi-Oh!', logos.yugioh, 'http://www.yugioh-card.com/') .setThumbnail(data.card_images[0].image_url) .setFooter(data.id.toString()) .addField('❯ Type', data.type, true) diff --git a/commands/voice/play.js b/commands/voice/play.js index e7aed577..3c9e2ca0 100644 --- a/commands/voice/play.js +++ b/commands/voice/play.js @@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); const ytdl = require('ytdl-core'); const { shorten, verify } = require('../../util/Util'); +const logos = require('../../assets/json/logos'); const { GOOGLE_KEY } = process.env; module.exports = class PlayCommand extends Command { @@ -88,7 +89,7 @@ module.exports = class PlayCommand extends Command { .setColor(0xDD2825) .setTitle(shorten(data.videoDetails.title, 70)) .setDescription(shorten(data.videoDetails.description, 100)) - .setAuthor('YouTube', 'https://i.imgur.com/kKHJg9Q.png', 'https://www.youtube.com/') + .setAuthor('YouTube', logos.youtube, 'https://www.youtube.com/') .setURL(data.videoDetails.video_url) .setThumbnail(data.videoDetails.thumbnails.length ? data.videoDetails.thumbnails[0].url : null) .addField('❯ ID', data.videoDetails.videoId, true)