mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Add Yu-Gi-Oh! Command
This commit is contained in:
@@ -61,7 +61,7 @@ class InfoCommand extends commando.Command {
|
||||
.addField('Modules',
|
||||
"[Commando](https://github.com/Gawdl3y/discord.js-commando) (0.9.0), [cleverbot-node](https://github.com/fojas/cleverbot-node) (0.3.5), [pirate-speak](https://github.com/mikewesthad/pirate-speak) (1.0.1), [JIMP](https://github.com/oliver-moran/jimp) (0.2.27), [google-translate-api](https://github.com/matheuss/google-translate-api) (2.2.2), [urban](https://github.com/mvrilo/urban) (0.3.1), [zalgoize](https://github.com/clux/zalgolize) (1.2.4), [hepburn](https://github.com/lovell/hepburn) (1.0.0), [wikifakt](https://github.com/coffee-cup/wikifakt) (1.0.3), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather) (2.2.2), [imdb-api](https://github.com/worr/node-imdb-api) (2.2.1), [request-promise](https://github.com/request/request-promise) (4.1.1)")
|
||||
.addField('Other Credit',
|
||||
"[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/)")
|
||||
"[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#)")
|
||||
.addField('My Server',
|
||||
"[Click Here to Join!](https://discord.gg/fqQF8mc)")
|
||||
.addField('Invite Link:',
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
const commando = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const request = require('request-promise');
|
||||
|
||||
class YuGiOhCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
super(Client, {
|
||||
name: 'yugioh',
|
||||
group: 'search',
|
||||
memberName: 'yugioh',
|
||||
description: 'Gets info on a Yu-Gi-Oh! Card. (;yugioh Blue-Eyes White Dragon)',
|
||||
examples: [';yugioh Blue-Eyes White Dragon']
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let cardname = message.content.split(" ").slice(1).join("%20");
|
||||
const options = {
|
||||
method: 'GET',
|
||||
uri: 'http://yugiohprices.com/api/card_data/' + cardname,
|
||||
json: true
|
||||
}
|
||||
request(options).then(function (response) {
|
||||
if(response.data.card_type === 'monster') {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.data.name)
|
||||
.setDescription(response.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.data.card_type, true)
|
||||
.addField('**Species:**',
|
||||
response.data.type, true)
|
||||
.addField('**Attribute:**',
|
||||
response.data.family, true)
|
||||
.addField('**ATK:**',
|
||||
response.data.atk, true)
|
||||
.addField('**DEF:**',
|
||||
response.data.def, true)
|
||||
.addField('**Level:**',
|
||||
response.data.level, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
} else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.data.name)
|
||||
.setDescription(response.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.data.card_type, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.sendMessage(":x: Error! Card not Found!\n:notepad_spiral: Note: This command is **extremely** sensitive to casing and dashes and whatnot. Type the *exact* card name to get data!");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = YuGiOhCommand;
|
||||
Reference in New Issue
Block a user