mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Fix Everything
This commit is contained in:
@@ -29,9 +29,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`)
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
.query({ q: query });
|
||||
const { anime } = await xml.parseStringAsync(text);
|
||||
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2000));
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -26,9 +26,7 @@ module.exports = class BotSearchCommand extends Command {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
|
||||
.set({
|
||||
Authorization: DBOTS_KEY
|
||||
});
|
||||
.set({ Authorization: DBOTS_KEY });
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
|
||||
|
||||
@@ -35,9 +35,7 @@ module.exports = class BulbapediaCommand extends Command {
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (body.query.pages[0].missing) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x3E7614)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class DanbooruCommand extends Command {
|
||||
@@ -28,9 +29,10 @@ module.exports = class DanbooruCommand extends Command {
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length || !body[0].file_url) {
|
||||
return msg.say('No Results');
|
||||
}
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
|
||||
if (!body.length || !body[0].file_url) return msg.say('No Results');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
https://danbooru.donmai.us${body[0].file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,9 +32,7 @@ module.exports = class DefineCommand extends Command {
|
||||
useCanonical: false,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!body.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(body[0].word)
|
||||
|
||||
@@ -17,11 +17,8 @@ module.exports = class DiscrimCommand extends Command {
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: (discrim) => {
|
||||
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Discriminator.';
|
||||
}
|
||||
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
|
||||
else return 'Invalid Discriminator.';
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -30,7 +27,7 @@ module.exports = class DiscrimCommand extends Command {
|
||||
|
||||
run(msg, args) {
|
||||
const discrim = args.discrim || msg.author.discriminator;
|
||||
const users = this.client.users.filter((u) => u.discriminator === discrim).map((u) => u.username);
|
||||
const users = this.client.users.filter((user) => user.discriminator === discrim).map((user) => user.username);
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${users.length} Users with the discriminator: ${discrim}`)
|
||||
.setDescription(users.join(', '));
|
||||
|
||||
+38
-11
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
@@ -25,12 +26,10 @@ module.exports = class ForecastCommand extends Command {
|
||||
const { body } = await snekfetch
|
||||
.get('https://query.yahooapis.com/v1/public/yql')
|
||||
.query({
|
||||
q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`,
|
||||
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${query}")`, // eslint-disable-line max-len
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) {
|
||||
return msg.say('Location Not Found.');
|
||||
}
|
||||
if (!body.query.count) return msg.say('Location Not Found.');
|
||||
const forecasts = body.query.results.channel.item.forecast;
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
@@ -38,19 +37,47 @@ module.exports = class ForecastCommand extends Command {
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField(`❯ ${forecasts[0].day} - ${forecasts[0].date}`,
|
||||
`**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[0].high}°F
|
||||
**Low:** ${forecasts[0].low}°F
|
||||
**Condition:** ${forecasts[0].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[1].day} - ${forecasts[1].date}`,
|
||||
`**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[1].high}°F
|
||||
**Low:** ${forecasts[1].low}°F
|
||||
**Condition:** ${forecasts[1].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[2].day} - ${forecasts[2].date}`,
|
||||
`**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[2].high}°F
|
||||
**Low:** ${forecasts[2].low}°F
|
||||
**Condition:** ${forecasts[2].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[3].day} - ${forecasts[3].date}`,
|
||||
`**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[3].high}°F
|
||||
**Low:** ${forecasts[3].low}°F
|
||||
**Condition:** ${forecasts[3].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[4].day} - ${forecasts[4].date}`,
|
||||
`**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[4].high}°F
|
||||
**Low:** ${forecasts[4].low}°F
|
||||
**Condition:** ${forecasts[4].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[5].day} - ${forecasts[5].date}`,
|
||||
`**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`)
|
||||
stripIndents`
|
||||
**High:** ${forecasts[5].high}°F
|
||||
**Low:** ${forecasts[5].low}°F
|
||||
**Condition:** ${forecasts[5].text}
|
||||
`)
|
||||
.addField(`❯ ${forecasts[6].day} - ${forecasts[6].date}`,
|
||||
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
||||
stripIndents`
|
||||
**High:** ${forecasts[6].high}°F
|
||||
**Low:** ${forecasts[6].low}°F
|
||||
**Condition:** ${forecasts[6].text}
|
||||
`);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+16
-14
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
@@ -23,19 +24,20 @@ module.exports = class GelbooruCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const { text } = await snekfetch
|
||||
.get('https://gelbooru.com/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||
const { text } = await snekfetch
|
||||
.get('https://gelbooru.com/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
Result for ${query}:
|
||||
https:${posts.post[0].$.file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,9 +28,7 @@ module.exports = class GiphyCommand extends Command {
|
||||
api_key: GIPHY_KEY,
|
||||
rating: msg.channel.nsfw ? 'r' : 'pg'
|
||||
});
|
||||
if (!body.data.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!body.data.length) return msg.say('No Results.');
|
||||
const random = Math.floor(Math.random() * body.data.length);
|
||||
return msg.say(body.data[random].images.original.url);
|
||||
}
|
||||
|
||||
@@ -25,14 +25,10 @@ module.exports = class GoogleCommand extends Command {
|
||||
const message = await msg.say('Searching...');
|
||||
const { text } = await snekfetch
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
.query({ q: query });
|
||||
const $ = cheerio.load(text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!href) return msg.say('No Results.');
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
return message.edit(href.q);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class KonachanCommand extends Command {
|
||||
@@ -28,9 +29,10 @@ module.exports = class KonachanCommand extends Command {
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
|
||||
if (!body.length) return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
https:${body[0].file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,9 +29,7 @@ module.exports = class MangaCommand extends Command {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/manga/search.xml`)
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
.query({ q: query });
|
||||
const { manga } = await xml.parseStringAsync(text);
|
||||
const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2000));
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -17,11 +17,8 @@ module.exports = class MapCommand extends Command {
|
||||
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
|
||||
type: 'integer',
|
||||
validate: (zoom) => {
|
||||
if (zoom < 21 && zoom > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Please enter a zoom value from 1-20';
|
||||
}
|
||||
if (zoom < 21 && zoom > 0) return true;
|
||||
else return 'Please enter a zoom value from 1-20';
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -30,9 +30,7 @@ module.exports = class NeopetCommand extends Command {
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
const link = $('textarea').first().text();
|
||||
if (!link.includes('cp')) {
|
||||
return msg.say('Invalid Pet Name.');
|
||||
}
|
||||
if (!link.includes('cp')) return msg.say('Invalid Pet Name.');
|
||||
return msg.say(link);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,9 +30,7 @@ module.exports = class OsuCommand extends Command {
|
||||
u: query,
|
||||
type: 'string'
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!body.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
@@ -33,9 +34,10 @@ module.exports = class Rule34Command extends Command {
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
Result for ${query}:
|
||||
https:${posts.post[0].$.file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,9 +29,7 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!body.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF15A22)
|
||||
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
|
||||
|
||||
@@ -24,12 +24,8 @@ module.exports = class UrbanCommand extends Command {
|
||||
const { query } = args;
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.urbandictionary.com/v0/define')
|
||||
.query({
|
||||
term: query
|
||||
});
|
||||
if (!body.list.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
.query({ term: query });
|
||||
if (!body.list.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
||||
|
||||
@@ -30,12 +30,8 @@ module.exports = class WattpadCommand extends Command {
|
||||
query,
|
||||
limit: 1
|
||||
})
|
||||
.set({
|
||||
Authorization: `Basic ${WATTPAD_KEY}`
|
||||
});
|
||||
if (!body.stories.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
.set({ Authorization: `Basic ${WATTPAD_KEY}` });
|
||||
if (!body.stories.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
||||
|
||||
@@ -25,12 +25,10 @@ module.exports = class WeatherCommand extends Command {
|
||||
const { body } = await snekfetch
|
||||
.get('https://query.yahooapis.com/v1/public/yql')
|
||||
.query({
|
||||
q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`,
|
||||
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${query}")`, // eslint-disable-line max-len
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) {
|
||||
return msg.say('Location Not Found.');
|
||||
}
|
||||
if (!body.query.count) return msg.say('Location Not Found.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
|
||||
@@ -34,9 +34,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (body.query.pages[0].missing) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
|
||||
@@ -32,9 +32,7 @@ module.exports = class YouTubeCommand extends Command {
|
||||
q: query,
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (!body.items.length) return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(body.items[0].snippet.title)
|
||||
|
||||
@@ -25,9 +25,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
const { query } = args;
|
||||
const { body } = await snekfetch
|
||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||
if (body.status === 'fail') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
if (body.status === 'fail') return msg.say('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
|
||||
Reference in New Issue
Block a user