mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 02:15:10 +02:00
Search group updates
This commit is contained in:
@@ -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}>
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user