snekfetch

This commit is contained in:
Daniel Odendahl Jr
2017-05-15 03:31:13 +00:00
parent d1148a0966
commit 87c0646233
40 changed files with 236 additions and 210 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ You can add XiaoBot to your server with [this link](https://discordapp.com/oauth
You can join the home server with [this link](https://discord.gg/fqQF8mc).
## Modules
[discord.js](https://discord.js.org), [commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://visionmedia.github.io/superagent), [mathjs](http://mathjs.org), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [canvas](https://github.com/Automattic/node-canvas), [cheerio](https://cheerio.js.org), [sequelize](http://docs.sequelizejs.com), [tsubaki](https://github.com/iCrawl/tsubaki), [node-opus](https://github.com/Rantanen/node-opus)
[discord.js](https://discord.js.org), [commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [snekfetch](https://github.com/devsnek/snekfetch), [mathjs](http://mathjs.org), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [canvas](https://github.com/Automattic/node-canvas), [cheerio](https://cheerio.js.org), [sequelize](http://docs.sequelizejs.com), [tsubaki](https://github.com/iCrawl/tsubaki), [node-opus](https://github.com/Rantanen/node-opus)
## APIs
[Wattpad](https://developer.wattpad.com), [Wordnik](http://developer.wordnik.com), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link), [YuGiOh](http://docs.yugiohprices.apiary.io), [YouTube](https://developers.google.com/youtube), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com), [Yahoo Weather](https://developer.yahoo.com/weather), [Google Maps](https://developers.google.com/maps), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [rrrather](http://www.rrrather.com/botapi), [SoundCloud](https://developers.soundcloud.com), [random.cat](http://random.cat), [random.dog](https://random.dog), [fixer.io](http://fixer.io), [konachan](https://konachan.net), [cleverbot.io](https://cleverbot.io), [My Anime List](https://myanimelist.net/modules.php?go=api)
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+2 -2
View File
@@ -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' }] })
+6 -3
View File
@@ -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:')
+7 -3
View File
@@ -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) {
+2 -2
View File
@@ -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`
+3 -4
View File
@@ -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)];
+2 -2
View File
@@ -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}...`)
+2 -2
View File
@@ -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));
+2 -2
View File
@@ -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));
+7 -6
View File
@@ -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, '')
+2 -2
View File
@@ -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()
+9 -3
View File
@@ -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)
+7 -3
View File
@@ -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()
+7 -5
View File
@@ -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.');
+8 -5
View File
@@ -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)
+7 -3
View File
@@ -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
View File
@@ -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) {
+9 -5
View File
@@ -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.');
+9 -5
View File
@@ -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)
+8 -5
View File
@@ -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)
+7 -5
View File
@@ -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)
+8 -5
View File
@@ -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()
+7 -3
View File
@@ -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)
+14 -5
View File
@@ -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)
+11 -5
View File
@@ -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)
+2 -2
View File
@@ -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') {
+2 -2
View File
@@ -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;
+51 -46
View File
@@ -11,56 +11,61 @@
<marquee behavior="scroll" direction="left">
<font size="25">XiaoBot, your personal server companion...</font>
</marquee>
<center>
<a href="https://discord.gg/fqQF8mc"><img src="https://discordapp.com/api/guilds/252317073814978561/embed.png" alt="Discord Server"></img></a>
</center>
<h3></h3>
<div class="xiaobox">
<center>
<h1><a href="https://github.com/dragonfire535/xiaobot">Source Code</a></h1>
</center>
<h2>Modules</h2>
<h2>Features</h2>
<ul>
<li><a href="https://discord.js.org">discord.js</a></li>
<li><a href="https://github.com/Gawdl3y/discord.js-commando/">discord.js-commando</a></li>
<li><a href="https://github.com/Automattic/node-canvas">canvas</a></li>
<li><a href="https://github.com/clux/zalgolize">zalgoize</a></li>
<li><a href="https://visionmedia.github.io/superagent">superagent</a></li>
<li><a href="http://mathjs.org">mathjs</a></li>
<li><a href="http://momentjs.com">moment</a></li>
<li><a href="https://github.com/jsmreese/moment-duration-format">moment-duration-format</a></li>
<li><a href="https://cheerio.js.org">cheerio</a></li>
<li><a href="http://docs.sequelizejs.com">sequelize</a></li>
<li><a href="https://github.com/iCrawl/tsubaki">tsubaki</a></li>
<li><a href="https://github.com/Rantanen/node-opus">node-opus</a></li>
<li>Cleverbot!</li>
<li>Avatar Image Editing, including Bob Ross, RIP, Wanted, Triggered, and more!</li>
<li>Profile Trading Cards, with random rarity!</li>
<li>Fun Games including Lottery, Math, Quiz, Rock Paper Scissors, Slots, and Typing!</li>
<li>Server and User Information!</li>
<li>Meme Generation!</li>
<li>Moderation Commands including Ban/Softban/Kick/Warn/Unban, Lockdown, and Prune, with Customizable Logging!</li>
<li>Currency and Temperature Conversion!</li>
<li>Tons of Secret Easter Eggs to discover!</li>
<li>Soundboard!</li>
<li>Calculator!</li>
<li>Strawpoll Generation!</li>
<li>Events that Happened today in history!</li>
<li>Would you rather questions!</li>
<li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li>
<li>8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!</li>
<li>Waifu and Ship Rating!</li>
<li>Random Roasts, Fortunes, and Compliments!</li>
<li>Random Fact Core Quotes!</li>
<li>Random Name Generation!</li>
<li>Random Anime Images (with NSFW)!</li>
<li>Roleplay Commands!</li>
<li>Search Various sites including:</li>
<ul>
<li>Google</li>
<li>Discord Bots</li>
<li>Yahoo Weather</li>
<li>IMDB</li>
<li>Google Maps</li>
<li>Neopet Images</li>
<li>Osu!</li>
<li>SoundCloud</li>
<li>Urban Dictionary</li>
<li>Wattpad</li>
<li>Wikipedia</li>
<li>YouTube</li>
<li>YuGiOh! Card Data</li>
<li>Konachan</li>
<li>My Anime List</li>
</ul>
<h2>APIs</h2>
<ul>
<li><a href="https://developer.wattpad.com">Wattpad</a></li>
<li><a href="http://developer.wordnik.com">Wordnik</a></li>
<li><a href="https://osu.ppy.sh/p/api">osu!</a></li>
<li><a href="https://memegen.link">memegen.link</a></li>
<li><a href="http://docs.yugiohprices.apiary.io">YuGiOh</a></li>
<li><a href="https://developers.google.com/youtube">YouTube</a></li>
<li><a href="https://bots.discord.pw/api">Discord Bots</a></li>
<li><a href="http://history.muffinlabs.com/#api">Today in History</a></li>
<li><a href="http://jservice.io">jService</a></li>
<li><a href="https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation">Urban Dictionary</a></li>
<li><a href="http://www.omdbapi.com">OMDB</a></li>
<li><a href="https://developer.yahoo.com/weather">Yahoo Weather</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps">Google Maps</a></li>
<li><a href="https://github.com/strawpoll/strawpoll/wiki/API">Strawpoll</a></li>
<li><a href="http://www.rrrather.com/botapi">rrrather</a></li>
<li><a href="https://developers.soundcloud.com">SoundCloud</a></li>
<li><a href="http://random.cat">random.cat</a></li>
<li><a href="https://random.dog">random.dog</a></li>
<li><a href="http://fixer.io">fixer.io</a></li>
<li><a href="https://konachan.net">konachan</a></li>
<li><a href="https://cleverbot.io">cleverbot.io</a></li>
<li><a href="https://myanimelist.net/modules.php?go=api">My Anime List</a></li>
</ul>
<h2>Information</h2>
<ul>
<li><a href="https://discord.gg/fqQF8mc">Home Server</a></li>
<li>Server Host: <a href="https://www.heroku.com/">Heroku</a></li>
<li>LMGTFY Link Generation!</li>
<li>Binary, Morse, Pirate, and Temmie Translators!</li>
<li>Cowsay, Embed, Reverse, Zalgo, and Upside Down Text!</li>
<li>Customizable Prefix!</li>
<li>Member Join/Leave Logging to a Customizable Channel, with a Customizable Message!</li>
<li>Customizable Staff Role able to use Mod Commands!</li>
<li>Optional "Single Role Mode" where only one role can use the bot's commands!</li>
<li>And so so so much more!</li>
</ul>
</div>
</div>
+1 -46
View File
@@ -5,6 +5,7 @@
<h3></h3>
<center>
<h1><a href="https://github.com/dragonfire535/xiaobot">Source Code</a></h1>
<a href="https://discord.gg/fqQF8mc"><img src="https://discordapp.com/api/guilds/252317073814978561/embed.png" alt="Discord Server"></img></a>
</center>
<h2>Features</h2>
<ul>
@@ -65,50 +66,4 @@
<li>Use x;help to View a Command List</li>
<li>Visit my <a href="https://discord.gg/fqQF8mc">Home Server</a> for more support, or for updates, or if you just want to hang out.</li>
</ol>
<h2>Modules</h2>
<ul>
<li><a href="https://discord.js.org">discord.js</a></li>
<li><a href="https://github.com/Gawdl3y/discord.js-commando/">discord.js-commando</a></li>
<li><a href="https://github.com/Automattic/node-canvas">canvas</a></li>
<li><a href="https://github.com/clux/zalgolize">zalgoize</a></li>
<li><a href="https://visionmedia.github.io/superagent">superagent</a></li>
<li><a href="http://mathjs.org">mathjs</a></li>
<li><a href="http://momentjs.com">moment</a></li>
<li><a href="https://github.com/jsmreese/moment-duration-format">moment-duration-format</a></li>
<li><a href="https://cheerio.js.org">cheerio</a></li>
<li><a href="http://docs.sequelizejs.com">sequelize</a></li>
<li><a href="https://github.com/iCrawl/tsubaki">tsubaki</a></li>
<li><a href="https://github.com/Rantanen/node-opus">node-opus</a></li>
</ul>
<h2>APIs</h2>
<ul>
<li><a href="https://developer.wattpad.com">Wattpad</a></li>
<li><a href="http://developer.wordnik.com">Wordnik</a></li>
<li><a href="https://osu.ppy.sh/p/api">osu!</a></li>
<li><a href="https://memegen.link">memegen.link</a></li>
<li><a href="http://docs.yugiohprices.apiary.io">YuGiOh</a></li>
<li><a href="https://developers.google.com/youtube">YouTube</a></li>
<li><a href="https://bots.discord.pw/api">Discord Bots</a></li>
<li><a href="http://history.muffinlabs.com/#api">Today in History</a></li>
<li><a href="http://jservice.io">jService</a></li>
<li><a href="https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation">Urban Dictionary</a></li>
<li><a href="http://www.omdbapi.com">OMDB</a></li>
<li><a href="https://developer.yahoo.com/weather">Yahoo Weather</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps">Google Maps</a></li>
<li><a href="https://github.com/strawpoll/strawpoll/wiki/API">Strawpoll</a></li>
<li><a href="http://www.rrrather.com/botapi">rrrather</a></li>
<li><a href="https://developers.soundcloud.com">SoundCloud</a></li>
<li><a href="http://random.cat">random.cat</a></li>
<li><a href="https://random.dog">random.dog</a></li>
<li><a href="http://fixer.io">fixer.io</a></li>
<li><a href="https://konachan.net">konachan</a></li>
<li><a href="https://cleverbot.io">cleverbot.io</a></li>
<li><a href="https://myanimelist.net/modules.php?go=api">My Anime List</a></li>
</ul>
<h2>Information</h2>
<ul>
<li><a href="https://discord.gg/fqQF8mc">Home Server</a></li>
<li>Server Host: <a href="https://www.heroku.com/">Heroku</a></li>
</ul>
</div>
+1 -1
View File
@@ -47,7 +47,7 @@
"node-opus": "^0.2.6",
"pg": "^6.1.5",
"sequelize": "^3.30.4",
"superagent": "^3.5.2",
"snekfetch": "^3.1.7",
"tsubaki": "^1.1.0",
"xml2js": "^0.4.17",
"zalgolize": "^1.2.4"
+3 -3
View File
@@ -1,9 +1,9 @@
const request = require('superagent');
const snekfetch = require('snekfetch');
const { CARBON_KEY, DBOTS_KEY } = process.env;
class Stats {
static dBots(server_count, id) {
request
snekfetch
.post(`https://bots.discord.pw/api/bots/${id}/stats`)
.set({ 'Authorization': DBOTS_KEY })
.send({ server_count })
@@ -12,7 +12,7 @@ class Stats {
}
static carbon(servercount) {
request
snekfetch
.post('https://www.carbonitex.net/discord/data/botdata.php')
.send({ key: CARBON_KEY, servercount })
.then(() => console.log('[DBots] Successfully posted to DBots.'))