From aceda6789976aa26682e0cd90149ed6afe06e1c4 Mon Sep 17 00:00:00 2001 From: lilyissillyyy Date: Sat, 30 Aug 2025 14:52:46 -0400 Subject: [PATCH] Search group updates --- README.md | 6 +---- commands/search/google.js | 45 ------------------------------- commands/search/know-your-meme.js | 8 ++++-- commands/search/periodic-table.js | 29 +++++--------------- commands/search/yu-gi-oh.js | 5 +--- package.json | 3 +-- 6 files changed, 16 insertions(+), 80 deletions(-) delete mode 100644 commands/search/google.js diff --git a/README.md b/README.md index 5d14598b..0ad05277 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ things, I'm not taking any chances. 19. Start Xiao up! ## Commands -Total: 514 +Total: 513 ### Utility: @@ -273,7 +273,6 @@ Total: 514 * **define:** Defines a word. * **frinkiac:** Input a line from the Simpsons to get the episode/season. * **github:** Responds with information on a GitHub repository. -* **google:** Searches Google. * **google-autofill:** Responds with a list of the Google Autofill results for a particular query. * **gravatar:** Responds with the Gravatar for an email. * **http-cat:** Responds with a cat for an HTTP status code. @@ -708,7 +707,6 @@ Total: 514 * [font-finder](https://www.npmjs.com/package/font-finder) * [gifencoder](https://www.npmjs.com/package/gifencoder) * [gm](https://www.npmjs.com/package/gm) -* [googlethis](https://www.npmjs.com/package/googlethis) * [html-entities](https://www.npmjs.com/package/html-entities) * [image-to-ascii](https://www.npmjs.com/package/image-to-ascii) * [ioredis](https://www.npmjs.com/package/ioredis) @@ -902,8 +900,6 @@ Total: 514 - [Frinkiac](https://frinkiac.com/) (API) * **github:** - [GitHub](https://github.com/) ([API](https://developer.github.com/v3/)) -* **google:** - - [Google](https://www.google.com/) (Search Results) * **google-autofill:** - [Google](https://www.google.com/) (Autofill API) * **gravatar:** diff --git a/commands/search/google.js b/commands/search/google.js deleted file mode 100644 index 56d0299e..00000000 --- a/commands/search/google.js +++ /dev/null @@ -1,45 +0,0 @@ -const Command = require('../../framework/Command'); -const google = require('googlethis'); -const { stripIndents } = require('common-tags'); - -module.exports = class GoogleCommand extends Command { - constructor(client) { - super(client, { - name: 'google', - aliases: ['google-this', 'search'], - group: 'search', - description: 'Searches Google.', - credit: [ - { - name: 'Google', - url: 'https://www.google.com/', - reason: 'Search Results' - } - ], - args: [ - { - key: 'query', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - const { results } = await google.search(query, { - page: 0, - safe: !msg.channel.nsfw, - parse_ads: false, - additional_params: { - hl: 'en' - } - }); - if (!results.length) return msg.reply('Could not find any results.'); - const result = results[0]; - return msg.reply(stripIndents` - **${result.title}** - ${result.description} - <${result.url}> - `); - } -}; diff --git a/commands/search/know-your-meme.js b/commands/search/know-your-meme.js index 6c4df880..b56c0047 100644 --- a/commands/search/know-your-meme.js +++ b/commands/search/know-your-meme.js @@ -46,9 +46,13 @@ module.exports = class KnowYourMemeCommand extends Command { async search(query) { const { text } = await request .get('https://knowyourmeme.com/search') - .query({ q: query }); + .query({ + q: query, + sort: 'views', + context: 'entries' + }); const $ = cheerio.load(text); - const location = $('.entry-grid-body').find('tr td a').first().attr('href'); + const location = $('section[class="gallery"]').find('a[class="item"]').first().attr('href'); if (!location) return null; return location; } diff --git a/commands/search/periodic-table.js b/commands/search/periodic-table.js index b20689da..b6448c68 100644 --- a/commands/search/periodic-table.js +++ b/commands/search/periodic-table.js @@ -1,25 +1,16 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); -const path = require('path'); +const { createCanvas } = require('@napi-rs/canvas'); const colors = { Solid: 'black', Liquid: 'blue', Gas: 'green' }; -const batman = { - name: 'Batman', - atomic_mass: 5.736e+28, - number: 0, - period: 'Gotham City', - phase: 'Solid', - symbol: '🦇' -}; const jerktonium = { name: 'Jerktonium', - atomic_mass: 240, - number: 1999, + atomic_mass: 1999, + number: 0, period: 'Bikini Bottom', phase: 'Solid', symbol: 'Jt' @@ -86,21 +77,16 @@ module.exports = class PeriodicTableCommand extends Command { ctx.fillStyle = 'white'; ctx.fillRect(10, 10, canvas.width - 20, canvas.height - 20); ctx.textAlign = 'center'; - if (element.number === 0) { - const batmanImg = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'batman.png')); - ctx.drawImage(batmanImg, 100, 166); - } else { - ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(210); - ctx.fillStyle = colors[element.phase] || 'gray'; - ctx.fillText(element.symbol, 250, 320); - } + ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(210); + ctx.fillStyle = colors[element.phase] || 'gray'; + ctx.fillText(element.symbol, 250, 320); ctx.fillStyle = 'black'; ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(45); ctx.fillText(element.number.toString(), 250, 100); ctx.fillText(element.name, 250, 450); ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(30); ctx.fillText(element.atomic_mass ? element.atomic_mass.toString() : '?', 250, 400); - const period = element.number === 0 || element.number === 1999 + const period = element.number === 0 ? element.period : `period ${element.period}`; const phase = element.undiscovered ? `hypothetical ${element.phase || 'element'}` : element.phase; @@ -115,7 +101,6 @@ module.exports = class PeriodicTableCommand extends Command { const { text } = await request .get('https://raw.githubusercontent.com/Bowserinator/Periodic-Table-JSON/master/PeriodicTableJSON.json'); this.table = JSON.parse(text).elements; - this.table.unshift(batman); this.table.unshift(jerktonium); return this.table; } diff --git a/commands/search/yu-gi-oh.js b/commands/search/yu-gi-oh.js index 4c6075e3..5bc17f6e 100644 --- a/commands/search/yu-gi-oh.js +++ b/commands/search/yu-gi-oh.js @@ -39,10 +39,7 @@ module.exports = class YuGiOhCommand extends Command { try { const { body } = await request .get('https://db.ygoprodeck.com/api/v7/cardinfo.php') - .query({ - fname: card, - la: 'english' - }); + .query({ fname: card }); const data = body.data[0]; const embed = new EmbedBuilder() .setColor(0xBE5F1F) diff --git a/package.json b/package.json index 1c997cbb..4311ea18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "154.0.0", + "version": "155.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -53,7 +53,6 @@ "font-finder": "^1.1.0", "gifencoder": "^2.0.1", "gm": "^1.25.1", - "googlethis": "github:CROSP/google-this", "html-entities": "^2.6.0", "image-to-ascii": "^3.2.2", "ioredis": "^5.7.0",