mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix ygo
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class YoutubeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'youtube',
|
||||
aliases: ['y-tube', 'u-tube', 'yt'],
|
||||
group: 'search',
|
||||
memberName: 'youtube',
|
||||
description: 'Searches YouTube for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'YouTube Data API',
|
||||
reasonURL: 'https://developers.google.com/youtube/v3/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What video would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
part: 'snippet',
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: query,
|
||||
safeSearch: msg.channel.nsfw ? 'none' : 'strict',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) return msg.say('Could not find any results.');
|
||||
const data = body.items[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(data.snippet.title)
|
||||
.setDescription(data.snippet.description)
|
||||
.setAuthor('YouTube', 'https://i.imgur.com/kKHJg9Q.png', 'https://www.youtube.com/')
|
||||
.setURL(`https://www.youtube.com/watch?v=${data.id.videoId}`)
|
||||
.setThumbnail(data.snippet.thumbnails.default ? data.snippet.thumbnails.default.url : null)
|
||||
.addField('❯ ID', data.id.videoId, true)
|
||||
.addField('❯ Publish Date', moment.utc(data.snippet.publishedAt).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Channel', data.snippet.channelTitle, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -58,11 +58,11 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
if (data.type.includes('Monster')) {
|
||||
embed
|
||||
.addField('❯ Attribute', data.attribute, true)
|
||||
.addField('❯ Level', data.level || 'N/A', true)
|
||||
.addField('❯ ATK', formatNumber(data.atk), true)
|
||||
.addField('❯ Level', data.level?.toString() || 'N/A', true)
|
||||
.addField('❯ ATK', formatNumber(data.atk).toString(), true)
|
||||
.addField(
|
||||
data.type === 'Link Monster' ? '❯ Link Value' : '❯ DEF',
|
||||
formatNumber(data.type === 'Link Monster' ? data.linkval : data.def),
|
||||
formatNumber(data.type === 'Link Monster' ? data.linkval : data.def).toString(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user