diff --git a/README.md b/README.md index ffd18683..f50fe6a9 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index b21d3289..4bab8ef5 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -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' }] }) diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index da023d26..d6b25fab 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -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' }] }) diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index da538b6f..e6aad4f7 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -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' }] }) diff --git a/commands/avataredit/card.js b/commands/avataredit/card.js index 729737a1..b43e9f98 100644 --- a/commands/avataredit/card.js +++ b/commands/avataredit/card.js @@ -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' }] }) diff --git a/commands/avataredit/greyscale.js b/commands/avataredit/greyscale.js index 3a6bafe5..55ee39bd 100644 --- a/commands/avataredit/greyscale.js +++ b/commands/avataredit/greyscale.js @@ -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' }] }) diff --git a/commands/avataredit/invert.js b/commands/avataredit/invert.js index 8e128997..5301f247 100644 --- a/commands/avataredit/invert.js +++ b/commands/avataredit/invert.js @@ -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' }] }) diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 38f0d8e8..a476299f 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -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' }] }) diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 87c9b17b..d4dd9274 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -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' }] }) diff --git a/commands/avataredit/triggered.js b/commands/avataredit/triggered.js index 4c4a7bd7..76e04f34 100644 --- a/commands/avataredit/triggered.js +++ b/commands/avataredit/triggered.js @@ -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' }] }) diff --git a/commands/avataredit/wanted.js b/commands/avataredit/wanted.js index 3eee79ab..96436a2f 100644 --- a/commands/avataredit/wanted.js +++ b/commands/avataredit/wanted.js @@ -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' }] }) diff --git a/commands/games/quiz.js b/commands/games/quiz.js index eb52f62d..13b5ef3b 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -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>)/g, ''); const embed = new RichEmbed() .setTitle('You have **15** seconds to answer this question:') diff --git a/commands/numedit/currency.js b/commands/numedit/currency.js index 71377c00..811694fa 100644 --- a/commands/numedit/currency.js +++ b/commands/numedit/currency.js @@ -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) { diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index 99329bf1..153a84ea 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -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` diff --git a/commands/random/today.js b/commands/random/today.js index 79df1442..8cdb7cd9 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -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)]; diff --git a/commands/random/wouldyourather.js b/commands/random/wouldyourather.js index 58c7c040..1a64bc6a 100644 --- a/commands/random/wouldyourather.js +++ b/commands/random/wouldyourather.js @@ -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}...`) diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index b11564a0..f45abe40 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -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)); diff --git a/commands/randomimg/dog.js b/commands/randomimg/dog.js index 8ef25dea..c49f0330 100644 --- a/commands/randomimg/dog.js +++ b/commands/randomimg/dog.js @@ -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)); diff --git a/commands/search/anime.js b/commands/search/anime.js index a1216d04..dcb9d814 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -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(/(
)/g, '') diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index 3909d8f8..6acef83f 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -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() diff --git a/commands/search/define.js b/commands/search/define.js index b58e0a01..231c2a3d 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -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) diff --git a/commands/search/forecast.js b/commands/search/forecast.js index a6f45cb2..9ed331f8 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -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() diff --git a/commands/search/google.js b/commands/search/google.js index 6820208a..2133993c 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -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.'); diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 9abd2875..b026695d 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -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) diff --git a/commands/search/konachan.js b/commands/search/konachan.js index be87a738..fae1de22 100644 --- a/commands/search/konachan.js +++ b/commands/search/konachan.js @@ -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)); diff --git a/commands/search/map.js b/commands/search/map.js index cf392cc1..e66579fd 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -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) { diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 24be511a..12b5d911 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -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.'); diff --git a/commands/search/osu.js b/commands/search/osu.js index c53011d0..91ac4944 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -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) diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index 966b79ab..a56b12cc 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -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) diff --git a/commands/search/urban.js b/commands/search/urban.js index e7801386..dadcba2f 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -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) diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 0d257912..dd5ea411 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -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() diff --git a/commands/search/weather.js b/commands/search/weather.js index f4da160b..5ac81492 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -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) diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 60f0e0e2..2e392fd3 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -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) diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 33257d1e..5e965cef 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -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) diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index a7191630..bd02e8d7 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -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') { diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 117780d0..1c59c413 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -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; diff --git a/html/carbondesc.html b/html/carbondesc.html index bc4e5908..cef843b6 100644 --- a/html/carbondesc.html +++ b/html/carbondesc.html @@ -11,56 +11,61 @@ XiaoBot, your personal server companion... +
+ Discord Server +

-
-

Source Code

-
-

Modules

+

Features

-

APIs

- -

Information

-
diff --git a/html/discordbots.html b/html/discordbots.html index 7d8dabf4..bde4ba75 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -5,6 +5,7 @@

Source Code

+ Discord Server

Features