mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 08:22:37 +02:00
snekfetch
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -41,7 +41,7 @@ module.exports = class YearsCommand extends Command {
|
||||
ctx.drawImage(avatar, 461, 127, 200, 200);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', '3000years.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'az.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -42,7 +42,7 @@ module.exports = class BeautifulCommand extends Command {
|
||||
ctx.drawImage(avatar, 343, 301, 117, 135);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'beautiful.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'grunkle.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -45,7 +45,7 @@ module.exports = class BobRossCommand extends Command {
|
||||
ctx.drawImage(base, 0, 0);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'bobross.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'ross.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const moment = require('moment');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
@@ -64,7 +64,7 @@ module.exports = class CardCommand extends Command {
|
||||
ctx.fillText(`#${member.user.discriminator}`, 313, 355);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'card.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class GreyscaleCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -44,7 +44,7 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
}
|
||||
ctx.putImageData(imgData, 0, 0);
|
||||
};
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
const avatarImg = await snekfetch.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class InvertCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -42,7 +42,7 @@ module.exports = class InvertCommand extends Command {
|
||||
}
|
||||
ctx.putImageData(imgData, 0, 0);
|
||||
};
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
const avatarImg = await snekfetch.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -50,7 +50,7 @@ module.exports = class RIPCommand extends Command {
|
||||
ctx.putImageData(imgData, 158, 51);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
const avatarImg = await snekfetch.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -46,7 +46,7 @@ module.exports = class SteamCardCommand extends Command {
|
||||
ctx.fillText(username, 35, 48);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steamcard.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -48,7 +48,7 @@ module.exports = class TriggeredCommand extends Command {
|
||||
ctx.drawImage(base, 0, 0);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'triggered.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'triggered.png' }] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
@@ -40,7 +40,7 @@ module.exports = class WantedCommand extends Command {
|
||||
ctx.drawImage(avatar, 150, 360, 430, 430);
|
||||
};
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
avatar.src = body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class QuizCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -19,8 +19,11 @@ module.exports = class QuizCommand extends Command {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('http://jservice.io/api/random?count=1');
|
||||
const { body } = await snekfetch
|
||||
.get('http://jservice.io/api/random')
|
||||
.query({
|
||||
count: 1
|
||||
});
|
||||
const answer = body[0].answer.toLowerCase().replace(/(<i>|<\/i>)/g, '');
|
||||
const embed = new RichEmbed()
|
||||
.setTitle('You have **15** seconds to answer this question:')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const codes = require('../../assets/json/currency');
|
||||
|
||||
module.exports = class CurrencyCommand extends Command {
|
||||
@@ -44,8 +44,12 @@ module.exports = class CurrencyCommand extends Command {
|
||||
const { base, to, amount } = args;
|
||||
if (base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.fixer.io/latest?base=${base}&symbols=${to}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.fixer.io/latest`)
|
||||
.query({
|
||||
base,
|
||||
symbols: to
|
||||
});
|
||||
const rate = body.rates[to];
|
||||
return msg.say(`${amount} ${base} is ${amount * rate} ${to}.`);
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class StrawpollCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -38,7 +38,7 @@ module.exports = class StrawpollCommand extends Command {
|
||||
if (options.length < 2) return msg.say('You provided less than two choices.');
|
||||
if (options.length > 31) return msg.say('You provided more than thirty choices.');
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.post('https://strawpoll.me/api/v2/polls')
|
||||
.send({ title, options });
|
||||
return msg.say(stripIndents`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class TodayCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -17,9 +17,8 @@ module.exports = class TodayCommand extends Command {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
try {
|
||||
const { text } = await request
|
||||
.get('http://history.muffinlabs.com/date')
|
||||
.buffer(true);
|
||||
const { text } = await snekfetch
|
||||
.get('http://history.muffinlabs.com/date');
|
||||
const parsed = JSON.parse(text);
|
||||
const events = parsed.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class WouldYouRatherCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -18,7 +18,7 @@ module.exports = class WouldYouRatherCommand extends Command {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.get('http://www.rrrather.com/botapi');
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${body.title}...`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class CatCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -17,7 +17,7 @@ module.exports = class CatCommand extends Command {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.get('http://random.cat/meow');
|
||||
return msg.channel.send({ files: [body.file] })
|
||||
.catch(err => msg.say(err));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class DogCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -16,7 +16,7 @@ module.exports = class DogCommand extends Command {
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.get('https://random.dog/woof.json');
|
||||
return msg.channel.send({ files: [body.url] })
|
||||
.catch(err => msg.say(err));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisify } = require('tsubaki');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
@@ -16,8 +16,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What anime would you like to search for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -29,9 +28,11 @@ module.exports = class AnimeCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { text } = await request
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml?q=${query}`)
|
||||
.buffer(true);
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`)
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
const { anime } = await xml(text);
|
||||
const synopsis = anime.entry[0].synopsis[0].substr(0, 2000)
|
||||
.replace(/(<br \/>)/g, '')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { DISCORD_BOTS_KEY } = process.env;
|
||||
|
||||
module.exports = class BotSearchCommand extends Command {
|
||||
@@ -26,7 +26,7 @@ module.exports = class BotSearchCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { bot } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
|
||||
.set({ 'Authorization': DISCORD_BOTS_KEY });
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
module.exports = class DefineCommand extends Command {
|
||||
@@ -27,8 +27,14 @@ module.exports = class DefineCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${WORDNIK_KEY}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`)
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
useCanonical: false,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class ForecastCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -25,8 +25,12 @@ module.exports = class ForecastCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
||||
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}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) throw new Error('Location Not Found.');
|
||||
const forecasts = body.query.results.channel.item.forecast;
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const querystring = require('querystring');
|
||||
|
||||
@@ -14,8 +14,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -25,8 +24,11 @@ module.exports = class GoogleCommand extends Command {
|
||||
const { query } = args;
|
||||
const message = await msg.say('Searching...');
|
||||
try {
|
||||
const { text } = await request
|
||||
.get(`https://www.google.com/search?q=${query}`);
|
||||
const { text } = await snekfetch
|
||||
.get(`https://www.google.com/search`)
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) throw new Error('No Results.');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class IMDBCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,8 +13,7 @@ module.exports = class IMDBCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What movie or TV Show would you like to search for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -26,8 +25,12 @@ module.exports = class IMDBCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://www.omdbapi.com/?t=${query}&plot=full`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://www.omdbapi.com/`)
|
||||
.query({
|
||||
t: query,
|
||||
plot: 'full'
|
||||
});
|
||||
if (body.Error) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDBA628)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class KonachanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -26,8 +26,12 @@ module.exports = class KonachanCommand extends Command {
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://konachan.net/post.json?tags=${query ? `${query}%20` : ''}order:random&limit=1`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://konachan.net/post.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
return msg.channel.send(query ? `Result for ${query}:` : 'Random Image:', { files: [`https:${body[0].file_url}`] })
|
||||
.catch(err => msg.say(err));
|
||||
|
||||
+10
-5
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class MapCommand extends Command {
|
||||
@@ -24,8 +24,7 @@ module.exports = class MapCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What location you like to get a map image for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -37,8 +36,14 @@ module.exports = class MapCommand extends Command {
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
const { zoom, query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://maps.googleapis.com/maps/api/staticmap?center=${query}&zoom=${zoom}&size=500x500&key=${GOOGLE_KEY}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: query,
|
||||
zoom,
|
||||
size: '500x500',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
return msg.channel.send({ files: [{ attachment: body, name: 'map.png' }] })
|
||||
.catch(err => msg.say(err));
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class NeopetCommand extends Command {
|
||||
@@ -13,8 +13,7 @@ module.exports = class NeopetCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What pet would you like to get the image of?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -23,8 +22,13 @@ module.exports = class NeopetCommand extends Command {
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { text } = await request
|
||||
.get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`);
|
||||
const { text } = await snekfetch
|
||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||
.query({
|
||||
name: query,
|
||||
size: 5,
|
||||
mood: 1
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
const link = $('textarea').first().text();
|
||||
if (!link.includes('cp')) throw new Error('Invalid Pet Name.');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { OSU_KEY } = process.env;
|
||||
|
||||
module.exports = class OsuCommand extends Command {
|
||||
@@ -14,8 +14,7 @@ module.exports = class OsuCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What osu username would you like to search for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -27,8 +26,13 @@ module.exports = class OsuCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://osu.ppy.sh/api/get_user?k=${OSU_KEY}&u=${query}&type=string`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({
|
||||
k: OSU_KEY,
|
||||
u: query,
|
||||
type: 'string'
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { SOUNDCLOUD_KEY } = process.env;
|
||||
|
||||
module.exports = class SoundCloudCommand extends Command {
|
||||
@@ -14,8 +14,7 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What do you want to search SoundCloud for?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -27,8 +26,12 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${SOUNDCLOUD_KEY}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.soundcloud.com/tracks`)
|
||||
.query({
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF15A22)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class UrbanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,8 +13,7 @@ module.exports = class UrbanCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to define?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -26,8 +25,11 @@ module.exports = class UrbanCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.urbandictionary.com/v0/define?term=${query}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.urbandictionary.com/v0/define`)
|
||||
.query({
|
||||
term: query
|
||||
});
|
||||
if (!body.list.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { WATTPAD_KEY } = process.env;
|
||||
|
||||
module.exports = class WattpadCommand extends Command {
|
||||
@@ -14,8 +14,7 @@ module.exports = class WattpadCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What book would you like to search for?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -27,8 +26,12 @@ module.exports = class WattpadCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`)
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.wattpad.com:443/v4/stories`)
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
})
|
||||
.set({ 'Authorization': `Basic ${WATTPAD_KEY}` });
|
||||
if (!body.stories.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class WeatherCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -25,8 +25,12 @@ module.exports = class WeatherCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`);
|
||||
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}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) throw new Error('Location Not Found.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class WikipediaCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,8 +13,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -26,8 +25,18 @@ module.exports = class WikipediaCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://en.wikipedia.org/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: query,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class YouTubeCommand extends Command {
|
||||
@@ -14,8 +14,7 @@ module.exports = class YouTubeCommand extends Command {
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -27,8 +26,15 @@ module.exports = class YouTubeCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${GOOGLE_KEY}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
part: 'snippet',
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: query,
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class YuGiOhCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -26,7 +26,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
return msg.say('This Command requires the `Embed Links` Permission.');
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await request
|
||||
const { body } = await snekfetch
|
||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||
if (body.status === 'fail') throw new Error('No Results.');
|
||||
if (body.data.card_type === 'monster') {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { WEBHOOK_URL } = process.env;
|
||||
|
||||
module.exports = class WebhookCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class WebhookCommand extends Command {
|
||||
const { content } = args;
|
||||
try {
|
||||
msg.delete();
|
||||
await request
|
||||
await snekfetch
|
||||
.post(WEBHOOK_URL)
|
||||
.send({ content });
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user