From b92eb79621ecc20438dee7b18ea6211029f84327 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 24 Mar 2024 13:10:26 -0400 Subject: [PATCH] Add drop shadow to who-pokemon --- .env.example | 5 -- commands/games-sp/fishy.js | 34 ----------- commands/games-sp/whos-that-pokemon.js | 2 + commands/search/bulbapedia.js | 62 ------------------- commands/search/deviantart.js | 74 ----------------------- commands/search/giphy.js | 46 -------------- commands/search/itunes.js | 78 ------------------------ commands/search/steam.js | 83 -------------------------- commands/search/weather.js | 66 -------------------- commands/search/wikia.js | 80 ------------------------- commands/search/wikihow.js | 54 ----------------- 11 files changed, 2 insertions(+), 582 deletions(-) delete mode 100644 commands/games-sp/fishy.js delete mode 100644 commands/search/bulbapedia.js delete mode 100644 commands/search/deviantart.js delete mode 100644 commands/search/giphy.js delete mode 100644 commands/search/itunes.js delete mode 100644 commands/search/steam.js delete mode 100644 commands/search/weather.js delete mode 100644 commands/search/wikia.js delete mode 100644 commands/search/wikihow.js diff --git a/.env.example b/.env.example index ab9a75ee..6d5fa308 100644 --- a/.env.example +++ b/.env.example @@ -33,14 +33,9 @@ NAME_RATER_EMOJI_ID= ANILIST_USERNAME= BITLY_KEY= CLEVERBOT_KEY= -DEVIANTART_ID= -DEVIANTART_SECRET= -GIPHY_KEY= GITHUB_ACCESS_TOKEN= GOOGLE_KEY= GOV_KEY= -OPENWEATHERMAP_KEY= -OSU_KEY= SPOTIFY_KEY= SPOTIFY_SECRET= USPS_USERID= diff --git a/commands/games-sp/fishy.js b/commands/games-sp/fishy.js deleted file mode 100644 index 78b7ebf2..00000000 --- a/commands/games-sp/fishy.js +++ /dev/null @@ -1,34 +0,0 @@ -const Command = require('../../framework/Command'); -const { randomRange } = require('../../util/Util'); -const fishes = require('../../assets/json/fishy'); - -module.exports = class FishyCommand extends Command { - constructor(client) { - super(client, { - name: 'fishy', - aliases: ['fishing', 'fish'], - group: 'games-sp', - memberName: 'fishy', - description: 'Go fishing.', - credit: [ - { - name: 'Tatsumaki', - url: 'https://tatsumaki.xyz/', - reason: 'Concept' - } - ] - }); - } - - run(msg) { - const fishID = Math.floor(Math.random() * 10) + 1; - let rarity; - if (fishID < 5) rarity = 'junk'; - else if (fishID < 8) rarity = 'common'; - else if (fishID < 10) rarity = 'uncommon'; - else rarity = 'rare'; - const fish = fishes[rarity]; - const worth = randomRange(fish.min, fish.max); - return msg.reply(`You caught a ${fish.symbol}. I bet it'd sell for around $${worth}.`); - } -}; diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index 16d8bbfc..75b6dde1 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -144,6 +144,8 @@ module.exports = class WhosThatPokemonCommand extends Command { ctx.lineWidth = 8; ctx.strokeStyle = '#3c5aa6'; ctx.strokeText(pokemon.name, 362, 158, 240); + ctx.fillStyle = 'black'; + ctx.fillText(pokemon.name, 357, 163, 240); ctx.fillStyle = '#ffcb05'; ctx.fillText(pokemon.name, 362, 158, 240); } diff --git a/commands/search/bulbapedia.js b/commands/search/bulbapedia.js deleted file mode 100644 index 747484df..00000000 --- a/commands/search/bulbapedia.js +++ /dev/null @@ -1,62 +0,0 @@ -const Command = require('../../framework/Command'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); -const { shorten } = require('../../util/Util'); - -module.exports = class BulbapediaCommand extends Command { - constructor(client) { - super(client, { - name: 'bulbapedia', - aliases: ['bulba'], - group: 'search', - memberName: 'bulbapedia', - description: 'Searches Bulbapedia for your query.', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'Bulbapedia', - url: 'https://bulbapedia.bulbagarden.net/wiki/Main_Page', - reason: 'API', - reasonURL: 'https://bulbapedia.bulbagarden.net/w/api.php' - } - ], - args: [ - { - key: 'query', - prompt: 'What article would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - try { - const { body } = await request - .get('https://bulbapedia.bulbagarden.net/w/api.php') - .query({ - action: 'query', - prop: 'extracts|pageimages', - format: 'json', - titles: query, - exintro: '', - explaintext: '', - pithumbsize: 150, - redirects: '', - formatversion: 2 - }); - const data = body.query.pages[0]; - if (data.missing) return msg.say('Could not find any results.'); - const embed = new MessageEmbed() - .setColor(0x3E7614) - .setTitle(data.title) - .setAuthor('Bulbapedia', 'https://i.imgur.com/ePpoeFA.png', 'https://bulbapedia.bulbagarden.net/') - .setThumbnail(data.thumbnail ? data.thumbnail.source : null) - .setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query).replaceAll(')', '%29')}`) - .setDescription(shorten(data.extract.replaceAll('\n', '\n\n'))); - return msg.embed(embed); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/deviantart.js b/commands/search/deviantart.js deleted file mode 100644 index 89bfbc64..00000000 --- a/commands/search/deviantart.js +++ /dev/null @@ -1,74 +0,0 @@ -const Command = require('../../framework/Command'); -const request = require('node-superfetch'); -const { list } = require('../../util/Util'); -const { DEVIANTART_ID, DEVIANTART_SECRET } = process.env; -const sections = ['dailydeviations', 'hot', 'newest', 'popular', 'undiscovered']; - -module.exports = class DeviantartCommand extends Command { - constructor(client) { - super(client, { - name: 'deviantart', - group: 'search', - memberName: 'deviantart', - description: 'Responds with an image from a DeviantArt section, with optional query.', - details: `**Sections:** ${sections.join(', ')}`, - credit: [ - { - name: 'DeviantArt', - url: 'https://www.deviantart.com/', - reason: 'API', - reasonURL: 'https://www.deviantart.com/developers/' - } - ], - args: [ - { - key: 'section', - prompt: `What section would you like to search? Either ${list(sections, 'or')}.`, - type: 'string', - oneOf: sections, - parse: section => section.toLowerCase() - }, - { - key: 'query', - prompt: 'What image would you like to search for?', - type: 'string', - default: '' - } - ] - }); - - this.token = null; - } - - async run(msg, { section, query }) { - try { - if (!this.token) await this.fetchToken(); - const { body } = await request - .get(`https://www.deviantart.com/api/v1/oauth2/browse/${section}`) - .query({ - q: query, - limit: 120, - access_token: this.token, - mature_content: msg.channel.nsfw || false - }); - const images = body.results.filter(image => image.content && image.content.src); - if (!images.length) return msg.say('Could not find any results.'); - return msg.say(images[Math.floor(Math.random() * images.length)].content.src); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } - - async fetchToken() { - const { body } = await request - .get('https://www.deviantart.com/oauth2/token') - .query({ - grant_type: 'client_credentials', - client_id: DEVIANTART_ID, - client_secret: DEVIANTART_SECRET - }); - this.token = body.access_token; - setTimeout(() => { this.token = null; }, body.expires_in * 1000); - return body; - } -}; diff --git a/commands/search/giphy.js b/commands/search/giphy.js deleted file mode 100644 index e45e81a1..00000000 --- a/commands/search/giphy.js +++ /dev/null @@ -1,46 +0,0 @@ -const Command = require('../../framework/Command'); -const request = require('node-superfetch'); -const { GIPHY_KEY } = process.env; - -module.exports = class GiphyCommand extends Command { - constructor(client) { - super(client, { - name: 'giphy', - aliases: ['gif'], - group: 'search', - memberName: 'giphy', - description: 'Searches Giphy for your query.', - credit: [ - { - name: 'GIPHY', - url: 'https://giphy.com/', - reason: 'API', - reasonURL: 'https://developers.giphy.com/' - } - ], - args: [ - { - key: 'query', - prompt: 'What GIF would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - try { - const { body } = await request - .get('http://api.giphy.com/v1/gifs/search') - .query({ - q: query, - api_key: GIPHY_KEY, - rating: msg.channel.nsfw ? 'r' : 'pg' - }); - if (!body.data.length) return msg.say('Could not find any results.'); - return msg.say(body.data[Math.floor(Math.random() * body.data.length)].images.original.url); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/itunes.js b/commands/search/itunes.js deleted file mode 100644 index 70a5f84b..00000000 --- a/commands/search/itunes.js +++ /dev/null @@ -1,78 +0,0 @@ -const Command = require('../../framework/Command'); -const moment = require('moment'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); - -module.exports = class ItunesCommand extends Command { - constructor(client) { - super(client, { - name: 'itunes', - group: 'search', - memberName: 'itunes', - description: 'Searches iTunes for your query.', - details: '**Codes:** ', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'Apple', - url: 'https://www.apple.com/', - reason: 'iTunes Search API', - reasonURL: 'https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/' - }, - { - name: 'Wikipedia', - url: 'https://www.wikipedia.org/', - reasonURL: 'https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes', - reason: 'Language Code Data' - } - ], - args: [ - { - key: 'country', - prompt: 'What country code should results be obtained for?', - type: 'string', - parse: country => country.toLowerCase() - }, - { - key: 'query', - prompt: 'What song would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { country, query }) { - try { - const { text } = await request - .get('https://itunes.apple.com/search') - .query({ - term: query, - media: 'music', - entity: 'song', - limit: 1, - explicit: msg.channel.nsfw ? 'yes' : 'no', - country - }); - const body = JSON.parse(text); - if (!body.results.length) return msg.say('Could not find any results.'); - const data = body.results[0]; - const embed = new MessageEmbed() - .setColor(0xFEFEFE) - .setAuthor('iTunes', 'https://i.imgur.com/PR29ow0.jpg', 'https://www.apple.com/itunes/') - .setURL(data.trackViewUrl) - .setThumbnail(data.artworkUrl100) - .setTitle(data.trackName) - .addField('❯ Artist', data.artistName, true) - .addField('❯ Album', data.collectionName, true) - .addField('❯ Release Date', moment.utc(data.releaseDate).format('MM/DD/YYYY'), true) - .addField('❯ Genre', data.primaryGenreName, true); - return msg.embed(embed); - } catch (err) { - if (err.status === 400) { - return msg.reply('Invalid country code. Refer to .'); - } - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/steam.js b/commands/search/steam.js deleted file mode 100644 index 6e14d0ab..00000000 --- a/commands/search/steam.js +++ /dev/null @@ -1,83 +0,0 @@ -const Command = require('../../framework/Command'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); -const { formatNumber } = require('../../util/Util'); - -module.exports = class SteamCommand extends Command { - constructor(client) { - super(client, { - name: 'steam', - group: 'search', - memberName: 'steam', - description: 'Searches Steam for your query.', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'Steam', - url: 'https://store.steampowered.com/', - reason: 'API' - } - ], - args: [ - { - key: 'query', - prompt: 'What game would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - try { - const id = await this.search(query); - if (!id) return msg.say('Could not find any results.'); - const data = await this.fetchGame(id); - const current = data.price_overview ? `$${data.price_overview.final / 100}` : 'Free'; - const original = data.price_overview ? `$${data.price_overview.initial / 100}` : 'Free'; - const price = current === original ? current : `~~${original}~~ ${current}`; - const platforms = []; - if (data.platforms) { - if (data.platforms.windows) platforms.push('Windows'); - if (data.platforms.mac) platforms.push('Mac'); - if (data.platforms.linux) platforms.push('Linux'); - } - const embed = new MessageEmbed() - .setColor(0x101D2F) - .setAuthor('Steam', 'https://i.imgur.com/xxr2UBZ.png', 'http://store.steampowered.com/') - .setTitle(data.name) - .setURL(`http://store.steampowered.com/app/${data.steam_appid}`) - .setThumbnail(data.header_image) - .addField('❯ Price', price, true) - .addField('❯ Metascore', data.metacritic ? data.metacritic.score : '???', true) - .addField('❯ Recommendations', data.recommendations ? formatNumber(data.recommendations.total) : '???', true) - .addField('❯ Platforms', platforms.join(', ') || 'None', true) - .addField('❯ Release Date', data.release_date ? data.release_date.date : '???', true) - .addField('❯ DLC Count', data.dlc ? formatNumber(data.dlc.length) : 0, true) - .addField('❯ Developers', data.developers ? data.developers.join(', ') || '???' : '???') - .addField('❯ Publishers', data.publishers ? data.publishers.join(', ') || '???' : '???'); - return msg.embed(embed); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } - - async search(query) { - const { body } = await request - .get('https://store.steampowered.com/api/storesearch') - .query({ - cc: 'us', - l: 'en', - term: query - }); - if (!body.items.length) return null; - return body.items[0].id; - } - - async fetchGame(id) { - const { body } = await request - .get('https://store.steampowered.com/api/appdetails') - .query({ appids: id }); - return body[id.toString()].data; - } -}; diff --git a/commands/search/weather.js b/commands/search/weather.js deleted file mode 100644 index ae7b9025..00000000 --- a/commands/search/weather.js +++ /dev/null @@ -1,66 +0,0 @@ -const Command = require('../../framework/Command'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); -const { OPENWEATHERMAP_KEY } = process.env; - -module.exports = class WeatherCommand extends Command { - constructor(client) { - super(client, { - name: 'weather', - aliases: ['open-weather-map', 'owm'], - group: 'search', - memberName: 'weather', - description: 'Responds with weather information for a specific location.', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'OpenWeatherMap', - url: 'https://openweathermap.org/', - reason: 'API', - reasonURL: 'https://openweathermap.org/api' - } - ], - args: [ - { - key: 'location', - prompt: 'What location would you like to get the weather of?', - type: 'string', - parse: location => { - if (/^[0-9]+$/.test(location)) return { type: 'zip', data: location }; - return { type: 'q', data: location }; - } - } - ] - }); - } - - async run(msg, { location }) { - try { - const { body } = await request - .get('https://api.openweathermap.org/data/2.5/weather') - .query({ - q: location.type === 'q' ? location.data : '', - zip: location.type === 'zip' ? location.data : '', - units: 'imperial', - appid: OPENWEATHERMAP_KEY - }); - const embed = new MessageEmbed() - .setColor(0xFF7A09) - .setAuthor( - `${body.name}, ${body.sys.country}`, - 'https://i.imgur.com/NjMbE9o.png', - 'https://openweathermap.org/city' - ) - .setURL(`https://openweathermap.org/city/${body.id}`) - .setTimestamp() - .addField('❯ Condition', body.weather.map(data => `${data.main} (${data.description})`).join('\n')) - .addField('❯ Temperature', `${body.main.temp}°F`, true) - .addField('❯ Humidity', `${body.main.humidity}%`, true) - .addField('❯ Wind Speed', `${body.wind.speed} mph`, true); - return msg.embed(embed); - } catch (err) { - if (err.status === 404) return msg.say('Could not find any results.'); - return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/wikia.js b/commands/search/wikia.js deleted file mode 100644 index ef820f11..00000000 --- a/commands/search/wikia.js +++ /dev/null @@ -1,80 +0,0 @@ -const Command = require('../../framework/Command'); -const { MessageEmbed } = require('discord.js'); -const request = require('node-superfetch'); - -module.exports = class WikiaCommand extends Command { - constructor(client) { - super(client, { - name: 'wikia', - aliases: ['fandom'], - group: 'search', - memberName: 'wikia', - description: 'Searches a specific Wikia wiki for your query.', - clientPermissions: ['EMBED_LINKS'], - credit: [ - { - name: 'FANDOM', - url: 'https://www.fandom.com/', - reason: 'API', - reasonURL: 'https://www.wikia.com/api/v1/' - } - ], - args: [ - { - key: 'wiki', - prompt: 'What is the subdomain of the wiki you want to search?', - type: 'string', - parse: wiki => encodeURIComponent(wiki) - }, - { - key: 'query', - prompt: 'What article would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { wiki, query }) { - try { - const id = await this.search(wiki, query); - if (!id) return msg.say('Could not find any results.'); - const { data, basePath } = await this.fetchArticle(wiki, id); - const embed = new MessageEmbed() - .setColor(0x002D54) - .setTitle(data.title) - .setURL(`${basePath}${data.url}`) - .setAuthor('FANDOM', 'https://i.imgur.com/kBDqFIN.png', 'https://www.fandom.com/') - .setDescription(data.abstract) - .setThumbnail(data.thumbnail); - return msg.embed(embed); - } catch (err) { - if (err.status === 404) return msg.say('Could not find any results.'); - return msg.say(`Oh no, an error occurred: \`${err.message}\`. Perhaps you entered an invalid wiki?`); - } - } - - async search(wiki, query) { - const { body } = await request - .get(`https://${wiki}.fandom.com/api.php`) - .query({ - action: 'query', - titles: query, - redirects: '', - format: 'json', - formatversion: 2 - }); - if (!body.query || body.query.pages[0].missing) return null; - return body.query.pages[0].pageid; - } - - async fetchArticle(wiki, id) { - const { body } = await request - .get(`https://${wiki}.fandom.com/api/v1/Articles/Details`) - .query({ - ids: id, - abstract: 500 - }); - return { data: body.items[id.toString()], basePath: body.basepath }; - } -}; diff --git a/commands/search/wikihow.js b/commands/search/wikihow.js deleted file mode 100644 index eb7964b1..00000000 --- a/commands/search/wikihow.js +++ /dev/null @@ -1,54 +0,0 @@ -const Command = require('../../framework/Command'); -const request = require('node-superfetch'); -const { stripIndents } = require('common-tags'); - -module.exports = class WikihowCommand extends Command { - constructor(client) { - super(client, { - name: 'wikihow', - aliases: ['how-to', 'how'], - group: 'search', - memberName: 'wikihow', - description: 'Searches Wikihow for your query.', - credit: [ - { - name: 'wikiHow', - url: 'https://www.wikihow.com/Main-Page', - reason: 'API', - reasonURL: 'https://www.wikihow.com/api.php' - } - ], - args: [ - { - key: 'query', - prompt: 'What article would you like to search for?', - type: 'string', - parse: query => query.replace(/^((how )?to )/i, '') - } - ] - }); - } - - async run(msg, { query }) { - try { - const { body } = await request - .get('https://www.wikihow.com/api.php') - .query({ - action: 'query', - prop: 'info', - format: 'json', - titles: query, - inprop: 'url', - redirects: '' - }); - const data = body.query.pages[Object.keys(body.query.pages)[0]]; - if (data.missing === '') return msg.say('Could not find any results.'); - return msg.say(stripIndents` - How to ${data.title} - ${data.fullurl} - `); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -};