mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
snekfetch -> superagent
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { KAIROS_KEY, KAIROS_ID } = process.env;
|
||||
const races = ['asian', 'black', 'hispanic', 'other', 'white'];
|
||||
|
||||
@@ -23,7 +23,7 @@ module.exports = class FaceAnalyzeCommand extends Command {
|
||||
|
||||
async run(msg, { face }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.post('https://api.kairos.com/detect')
|
||||
.set({
|
||||
app_id: KAIROS_ID,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class GenderAnalyzeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -33,7 +33,7 @@ module.exports = class GenderAnalyzeCommand extends Command {
|
||||
|
||||
async run(msg, { first, last }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://api.namsor.com/onomastics/api/json/gender/${first}/${last}`);
|
||||
const { body } = await request.get(`https://api.namsor.com/onomastics/api/json/gender/${first}/${last}`);
|
||||
if (body.gender === 'unknown') return msg.say(`I have no idea what gender ${body.firstName} is.`);
|
||||
return msg.say(`I'm ${Math.abs(body.scale * 100)}% sure ${body.firstName} is a ${body.gender} name.`);
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class ReadQRCodeCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class ReadQRCodeCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://api.qrserver.com/v1/read-qr-code/')
|
||||
.query({ fileurl: image });
|
||||
const data = body[0].symbol[0];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class SevereToxicityCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class SevereToxicityCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.post('https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze')
|
||||
.query({ key: GOOGLE_KEY })
|
||||
.send({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class SpoopyLinkCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class SpoopyLinkCommand extends Command {
|
||||
|
||||
async run(msg, { site }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://spoopy.link/api/${site}`);
|
||||
const { body } = await request.get(`https://spoopy.link/api/${site}`);
|
||||
return msg.say(stripIndents`
|
||||
${body.safe ? 'Safe!' : 'Not safe...'}
|
||||
${body.chain.map(url => `<${url.url}> ${url.safe ? '✅' : `❌ (${url.reasons.join(', ')})`}`).join('\n')}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class ToxicityCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class ToxicityCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.post('https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze')
|
||||
.query({ key: GOOGLE_KEY })
|
||||
.send({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class ThreeThousandYearsCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class ThreeThousandYearsCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', '3000-years.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class ApprovedCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class ApprovedCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'approved.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class AvatarFusionCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -35,9 +35,9 @@ module.exports = class AvatarFusionCommand extends Command {
|
||||
const baseAvatarURL = base.displayAvatarURL({ format: 'png', size: 512 });
|
||||
const overlayAvatarURL = overlay.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const baseAvatarData = await snekfetch.get(baseAvatarURL);
|
||||
const baseAvatarData = await request.get(baseAvatarURL);
|
||||
const baseAvatar = await loadImage(baseAvatarData.body);
|
||||
const overlayAvatarData = await snekfetch.get(overlayAvatarURL);
|
||||
const overlayAvatarData = await request.get(overlayAvatarURL);
|
||||
const overlayAvatar = await loadImage(overlayAvatarData.body);
|
||||
const canvas = createCanvas(baseAvatar.width, baseAvatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class BeautifulCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class BeautifulCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'beautiful.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class BobRossCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class BobRossCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'bob-ross.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { randomRange } = require('../../util/Util');
|
||||
const { version } = require('../../package');
|
||||
@@ -41,7 +41,7 @@ module.exports = class CardCommand extends Command {
|
||||
else if (cardID < 9000) rarity = 'U';
|
||||
else rarity = 'R';
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'card.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class ChallengerCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class ChallengerCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class DexterCommand extends Command {
|
||||
@@ -30,7 +30,7 @@ module.exports = class DexterCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'dexter.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class DistractedBoyfriendCommand extends Command {
|
||||
@@ -43,11 +43,11 @@ module.exports = class DistractedBoyfriendCommand extends Command {
|
||||
const otherGirlAvatarURL = otherGirl.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'distracted-boyfriend.png'));
|
||||
const boyfriendAvatarData = await snekfetch.get(boyfriendAvatarURL);
|
||||
const boyfriendAvatarData = await request.get(boyfriendAvatarURL);
|
||||
const boyfriendAvatar = await loadImage(boyfriendAvatarData.body);
|
||||
const girlfriendAvatarData = await snekfetch.get(girlfriendAvatarURL);
|
||||
const girlfriendAvatarData = await request.get(girlfriendAvatarURL);
|
||||
const girlfriendAvatar = await loadImage(girlfriendAvatarData.body);
|
||||
const otherGirlAvatarData = await snekfetch.get(otherGirlAvatarURL);
|
||||
const otherGirlAvatarData = await request.get(otherGirlAvatarURL);
|
||||
const otherGirlAvatar = await loadImage(otherGirlAvatarData.body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class FireCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'fire.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { contrast } = require('../../util/Canvas');
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class FoodBrokeCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 128 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'food-broke.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { list } = require('../../util/Util');
|
||||
const hats = require('../../assets/json/hat');
|
||||
@@ -40,7 +40,7 @@ module.exports = class HatCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'hat', `${type}.png`));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class HeLivesInYouCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'he-lives-in-you.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class IHaveThePowerCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class IHaveThePowerCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'i-have-the-power.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class LookAtThisPhotographCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class LookAtThisPhotographCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-at-this-photograph.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class LookWhatKarenHaveCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class LookWhatKarenHaveCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-what-karen-have.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class PixelizeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -28,7 +28,7 @@ module.exports = class PixelizeCommand extends Command {
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 64 });
|
||||
try {
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(512, 512);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RainbowCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class RainbowCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rainbow.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RejctedCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class RejctedCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rejected.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class RipCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
||||
@@ -34,7 +34,7 @@ module.exports = class SteamCardCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { shortenText } = require('../../util/Canvas');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||
@@ -40,7 +40,7 @@ module.exports = class SteamNowPlayingCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 64 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-now-playing.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class TheUltimateTattooCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class TheUltimateTattooCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'the-ultimate-tattoo.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class ThugLifeCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'thug-life.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class TriggeredCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'triggered.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { sepia } = require('../../util/Canvas');
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class WantedCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class YuGiOhTokenCommand extends Command {
|
||||
@@ -31,7 +31,7 @@ module.exports = class YuGiOhTokenCommand extends Command {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-token.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const { GOV_KEY } = process.env;
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = class AstronomyPictureOfTheDayCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://api.nasa.gov/planetary/apod')
|
||||
.query({ api_key: GOV_KEY });
|
||||
return msg.say(shorten(body.explanation), { files: [body.url] });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class DoomsdayClockCommand extends Command {
|
||||
@@ -14,8 +14,7 @@ module.exports = class DoomsdayClockCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { raw } = await snekfetch.get('https://thebulletin.org/timeline');
|
||||
const text = raw.toString();
|
||||
const { text } = await request.get('https://thebulletin.org/timeline');
|
||||
const time = text.match(/IT IS (.+) MINUTES TO MIDNIGHT/)[0];
|
||||
const desc = text.match(/<div class="body-text"><span class="timeline-year">(.+)<\/span>: (.+)<\/div>/);
|
||||
return msg.say(stripIndents`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class GoogleDoodleCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -32,7 +32,7 @@ module.exports = class GoogleDoodleCommand extends Command {
|
||||
if (latest) month = now.getMonth() + 1;
|
||||
if (!year) year = now.getFullYear();
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://www.google.com/doodles/json/${year}/${month}`);
|
||||
const { body } = await request.get(`https://www.google.com/doodles/json/${year}/${month}`);
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const data = body[latest ? 0 : Math.floor(Math.random() * body.length)];
|
||||
const runDate = new Date(data.run_date_array.join('-')).toDateString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { today, tomorrow } = require('../../util/Util');
|
||||
const { GOOGLE_KEY, GOOGLE_CALENDAR_ID } = process.env;
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class HolidaysCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(GOOGLE_CALENDAR_ID)}/events`)
|
||||
.query({
|
||||
maxResults: 10,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { list } = require('../../util/Util');
|
||||
const signs = require('../../assets/json/horoscope');
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = class HoroscopeCommand extends Command {
|
||||
|
||||
async run(msg, { sign }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`http://theastrologer-api.herokuapp.com/api/horoscope/${sign}/today`);
|
||||
const { body } = await request.get(`http://theastrologer-api.herokuapp.com/api/horoscope/${sign}/today`);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(`Horoscope for ${body.sunsign}...`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { list, duration, tomorrow } = require('../../util/Util');
|
||||
const { GOLD_FISH_EMOJI_ID, SILVER_FISH_EMOJI_ID } = process.env;
|
||||
@@ -42,9 +42,9 @@ module.exports = class NekoAtsumePasswordCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchPassword(locale) {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get(`http://hpmobile.jp/app/nekoatsume/neko_daily${locale !== 'jp' ? `_${locale}` : ''}.php`);
|
||||
const data = raw.toString().split(',');
|
||||
const data = text.split(',');
|
||||
const date = new Date();
|
||||
date.setUTCHours(date.getUTCHours() + 9);
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class TodayInHistoryCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -33,8 +33,8 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
async run(msg, { month, day }) {
|
||||
const date = month && day ? `/${month}/${day}` : '';
|
||||
try {
|
||||
const { raw } = await snekfetch.get(`http://history.muffinlabs.com/date${date}`);
|
||||
const body = JSON.parse(raw.toString());
|
||||
const { text } = await request.get(`http://history.muffinlabs.com/date${date}`);
|
||||
const body = JSON.parse(text);
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
const embed = new MessageEmbed()
|
||||
@@ -47,7 +47,7 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
event.links.map(link => `[${link.title}](${link.link.replace(/\)/g, '%29')})`).join(', '));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.statusCode === 404 || err.statusCode === 500) return msg.say('Invalid date.');
|
||||
if (err.status === 404 || err.status === 500) return msg.say('Invalid date.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class WordOfTheDayCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://api.wordnik.com/v4/words.json/wordOfTheDay')
|
||||
.query({ api_key: WORDNIK_KEY });
|
||||
return msg.say(stripIndents`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { verify } = require('../../util/Util');
|
||||
|
||||
@@ -64,7 +64,7 @@ module.exports = class AkinatorCommand extends Command {
|
||||
}
|
||||
|
||||
async createSession(channel) {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://192.99.38.142:8126/ws/new_session')
|
||||
.query({
|
||||
partner: 1,
|
||||
@@ -87,7 +87,7 @@ module.exports = class AkinatorCommand extends Command {
|
||||
|
||||
async progress(channel, answer) {
|
||||
const session = this.sessions.get(channel.id);
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://192.99.38.142:8126/ws/answer')
|
||||
.query({
|
||||
session: session.id,
|
||||
@@ -110,7 +110,7 @@ module.exports = class AkinatorCommand extends Command {
|
||||
|
||||
async finish(channel) {
|
||||
const session = this.sessions.get(channel.id);
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://192.99.38.142:8126/ws/list')
|
||||
.query({
|
||||
session: session.id,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const questions = require('../../assets/json/google-feud');
|
||||
|
||||
@@ -66,13 +66,13 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchSuggestions(question) {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('https://suggestqueries.google.com/complete/search')
|
||||
.query({
|
||||
client: 'firefox',
|
||||
q: question
|
||||
});
|
||||
const suggestions = JSON.parse(raw.toString())[1]
|
||||
const suggestions = JSON.parse(text)[1]
|
||||
.filter(suggestion => suggestion.toLowerCase() !== question.toLowerCase());
|
||||
if (!suggestions.length) return null;
|
||||
return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class HangmanCommand extends Command {
|
||||
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
|
||||
this.playing.add(msg.channel.id);
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://api.wordnik.com/v4/words.json/randomWord')
|
||||
.query({ api_key: WORDNIK_KEY });
|
||||
const word = body.word.toLowerCase().replace(/ /g, '-');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shuffle, list } = require('../../util/Util');
|
||||
const types = ['multiple', 'boolean'];
|
||||
const difficulties = ['easy', 'medium', 'hard'];
|
||||
@@ -41,7 +41,7 @@ module.exports = class QuizCommand extends Command {
|
||||
|
||||
async run(msg, { type, difficulty }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://opentdb.com/api.php')
|
||||
.query({
|
||||
amount: 1,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { silhouette } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class WhosThatPokemonCommand extends Command {
|
||||
@@ -52,13 +52,13 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
|
||||
async fetchPokemon(pokemon) {
|
||||
if (this.cache.has(pokemon)) return this.cache.get(pokemon);
|
||||
const { body } = await snekfetch.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
||||
const { body } = await request.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
||||
this.cache.set(body.id, body);
|
||||
return body;
|
||||
}
|
||||
|
||||
async fetchImage(id, hide = false) {
|
||||
const image = await snekfetch.get(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
const image = await request.get(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
if (!hide) return image.body;
|
||||
const base = await loadImage(image.body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { contrast } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ContrastCommand extends Command {
|
||||
@@ -28,7 +28,7 @@ module.exports = class ContrastCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class CreateQRCodeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -21,7 +21,7 @@ module.exports = class CreateQRCodeCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://api.qrserver.com/v1/create-qr-code/')
|
||||
.query({ data: text });
|
||||
return msg.say({ files: [{ attachment: body, name: 'qr-code.png' }] });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
const { shortenText } = require('../../util/Canvas');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||
@@ -45,7 +45,7 @@ module.exports = class DemotivationalPosterCommand extends Command {
|
||||
async run(msg, { title, text, image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'demotivational-poster.png'));
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { distort } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class DistortCommand extends Command {
|
||||
@@ -34,7 +34,7 @@ module.exports = class DistortCommand extends Command {
|
||||
|
||||
async run(msg, { level, image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class FrameCommand extends Command {
|
||||
@@ -30,7 +30,7 @@ module.exports = class FrameCommand extends Command {
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'frame.png'));
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { distort } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class GlitchCommand extends Command {
|
||||
@@ -28,7 +28,7 @@ module.exports = class GlitchCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class GreyscaleCommand extends Command {
|
||||
@@ -29,7 +29,7 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class IfunnyCommand extends Command {
|
||||
@@ -29,7 +29,7 @@ module.exports = class IfunnyCommand extends Command {
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ifunny.png'));
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { wait } = require('../../util/Util');
|
||||
|
||||
module.exports = class IllegalCommand extends Command {
|
||||
@@ -46,7 +46,7 @@ module.exports = class IllegalCommand extends Command {
|
||||
}
|
||||
|
||||
async createGIF(text) {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.post('https://is-now-illegal.firebaseio.com/queue/tasks.json')
|
||||
.send({
|
||||
task: 'gif',
|
||||
@@ -57,7 +57,7 @@ module.exports = class IllegalCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchGIF(text) {
|
||||
const { body } = await snekfetch.get(`https://is-now-illegal.firebaseio.com/gifs/${text}.json`);
|
||||
const { body } = await request.get(`https://is-now-illegal.firebaseio.com/gifs/${text}.json`);
|
||||
if (!body) return null;
|
||||
return body.url;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { invert } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class InvertCommand extends Command {
|
||||
@@ -28,7 +28,7 @@ module.exports = class InvertCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class MemeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -36,9 +36,9 @@ module.exports = class MemeCommand extends Command {
|
||||
|
||||
async run(msg, { type, top, bottom }) {
|
||||
try {
|
||||
const search = await snekfetch.get(`https://memegen.link/api/search/${type}`);
|
||||
const search = await request.get(`https://memegen.link/api/search/${type}`);
|
||||
if (!search.body.length) return msg.say('Could not find any results.');
|
||||
const { body } = await snekfetch.get(search.body[0].template.blank.replace(/\/_/, `/${top}/${bottom}`));
|
||||
const { body } = await request.get(search.body[0].template.blank.replace(/\/_/, `/${top}/${bottom}`));
|
||||
return msg.say({ files: [{ attachment: body, name: 'meme.jpg' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { list } = require('../../util/Util');
|
||||
const colors = require('../../assets/json/osu-signature');
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = class OsuSignatureCommand extends Command {
|
||||
|
||||
async run(msg, { user, color }) {
|
||||
try {
|
||||
const { body, raw } = await snekfetch
|
||||
const { body, raw } = await request
|
||||
.get('https://lemmmy.pw/osusig/sig.php')
|
||||
.query({
|
||||
colour: color,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class RobohashCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -22,7 +22,7 @@ module.exports = class RobohashCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://robohash.org/${text}`);
|
||||
const { body } = await request.get(`https://robohash.org/${text}`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'robohash.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { sepia } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class SepiaCommand extends Command {
|
||||
@@ -28,7 +28,7 @@ module.exports = class SepiaCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class ShieldsIoBadgeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -35,10 +35,10 @@ module.exports = class ShieldsIoBadgeCommand extends Command {
|
||||
|
||||
async run(msg, { subject, status, color }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://img.shields.io/badge/${subject}-${status}-${color}.png`);
|
||||
const { body } = await request.get(`https://img.shields.io/badge/${subject}-${status}-${color}.png`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'badge.png' }] });
|
||||
} catch (err) {
|
||||
if (err.statusCode === 404) return msg.reply('Could not create the badge...');
|
||||
if (err.status === 404) return msg.reply('Could not create the badge...');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { silhouette } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class SilhouetteCommand extends Command {
|
||||
@@ -28,7 +28,7 @@ module.exports = class SilhouetteCommand extends Command {
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class TintCommand extends Command {
|
||||
@@ -34,7 +34,7 @@ module.exports = class TintCommand extends Command {
|
||||
|
||||
async run(msg, { color, image }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(image);
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { list } = require('../../util/Util');
|
||||
const codes = require('../../assets/json/currency');
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = class CurrencyCommand extends Command {
|
||||
async run(msg, { base, target, amount }) {
|
||||
if (base === target) return msg.say(`Converting ${base} to ${target} is the same value, dummy.`);
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://api.fixer.io/latest')
|
||||
.query({
|
||||
base,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class StrawpollCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -32,7 +32,7 @@ module.exports = class StrawpollCommand extends Command {
|
||||
if (options.length < 2) return msg.reply('Please provide more than one choice.');
|
||||
if (options.length > 31) return msg.reply('Please provide thirty or less choices.');
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.post('https://www.strawpoll.me/api/v2/polls')
|
||||
.set({ 'Content-Type': 'application/json' })
|
||||
.send({ title, options });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class AdviceSlipCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -14,8 +14,8 @@ module.exports = class AdviceSlipCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { raw } = await snekfetch.get('http://api.adviceslip.com/advice');
|
||||
return msg.say(JSON.parse(raw.toString()).slip.advice);
|
||||
const { text } = await request.get('http://api.adviceslip.com/advice');
|
||||
return msg.say(JSON.parse(text).slip.advice);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { THE_CAT_API_KEY } = process.env;
|
||||
|
||||
module.exports = class CatCommand extends Command {
|
||||
@@ -16,7 +16,7 @@ module.exports = class CatCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body, headers } = await snekfetch
|
||||
const { body, headers } = await request
|
||||
.get('http://thecatapi.com/api/images/get')
|
||||
.query({ api_key: THE_CAT_API_KEY });
|
||||
const format = headers['content-type'].replace(/image\//i, '');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class ChuckNorrisCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -22,7 +22,7 @@ module.exports = class ChuckNorrisCommand extends Command {
|
||||
|
||||
async run(msg, { name }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://api.icndb.com/jokes/random')
|
||||
.query({
|
||||
escape: 'javascript',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class DogCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -15,7 +15,7 @@ module.exports = class DogCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch.get('https://dog.ceo/api/breeds/image/random');
|
||||
const { body } = await request.get('https://dog.ceo/api/breeds/image/random');
|
||||
return msg.say({ files: [body.message] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class FactCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -15,7 +15,7 @@ module.exports = class FactCommand extends Command {
|
||||
async run(msg) {
|
||||
try {
|
||||
const article = await this.randomWikipediaArticle();
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://en.wikipedia.org/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
@@ -40,7 +40,7 @@ module.exports = class FactCommand extends Command {
|
||||
}
|
||||
|
||||
async randomWikipediaArticle() {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://en.wikipedia.org/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const { NYTIMES_KEY } = process.env;
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class NewYorkTimesCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const fetch = snekfetch
|
||||
const fetch = request
|
||||
.get('https://api.nytimes.com/svc/search/v2/articlesearch.json')
|
||||
.query({
|
||||
'api-key': NYTIMES_KEY,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class NumberFactCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -20,10 +20,10 @@ module.exports = class NumberFactCommand extends Command {
|
||||
|
||||
async run(msg, { number }) {
|
||||
try {
|
||||
const { raw } = await snekfetch.get(`http://numbersapi.com/${number}`);
|
||||
return msg.say(raw.toString());
|
||||
const { text } = await request.get(`http://numbersapi.com/${number}`);
|
||||
return msg.say(text);
|
||||
} catch (err) {
|
||||
if (err.statusCode === 404) return msg.say('Could not find any results.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class RedditCommand extends Command {
|
||||
@@ -23,7 +23,7 @@ module.exports = class RedditCommand extends Command {
|
||||
|
||||
async run(msg, { subreddit }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://www.reddit.com/r/${subreddit}/new.json`)
|
||||
.query({ sort: 'new' });
|
||||
const allowed = msg.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
|
||||
@@ -37,8 +37,8 @@ module.exports = class RedditCommand extends Command {
|
||||
⬇ ${post.downs}
|
||||
`);
|
||||
} catch (err) {
|
||||
if (err.statusCode === 403) return msg.say('This subreddit is private.');
|
||||
if (err.statusCode === 404) return msg.say('Could not find any results.');
|
||||
if (err.status === 403) return msg.say('This subreddit is private.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class ShowerThoughtCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -14,7 +14,7 @@ module.exports = class ShowerThoughtCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://www.reddit.com/r/Showerthoughts.json')
|
||||
.query({ limit: 1000 });
|
||||
const allowed = msg.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class BulbapediaCommand extends Command {
|
||||
@@ -24,7 +24,7 @@ module.exports = class BulbapediaCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://bulbapedia.bulbagarden.net/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class DanbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -27,7 +27,7 @@ module.exports = class DanbooruCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://danbooru.donmai.us/posts.json')
|
||||
.query({
|
||||
tags: `${query} order:random`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { list } = require('../../util/Util');
|
||||
const { DEVIANTART_ID, DEVIANTART_SECRET } = process.env;
|
||||
const sections = ['dailydeviations', 'hot', 'newest', 'popular', 'undiscovered'];
|
||||
@@ -35,7 +35,7 @@ module.exports = class DeviantartCommand extends Command {
|
||||
async run(msg, { section, query }) {
|
||||
try {
|
||||
if (!this.token) await this.fetchToken();
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://www.deviantart.com/api/v1/oauth2/browse/${section}`)
|
||||
.query({
|
||||
q: query,
|
||||
@@ -52,7 +52,7 @@ module.exports = class DeviantartCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchToken() {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://www.deviantart.com/oauth2/token')
|
||||
.query({
|
||||
grant_type: 'client_credentials',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = class DictionaryCommand extends Command {
|
||||
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`http://api.wordnik.com/v4/word.json/${word}/definitions`)
|
||||
.query({
|
||||
limit: 1,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { FLICKR_KEY } = process.env;
|
||||
|
||||
module.exports = class FlickrCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class FlickrCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://api.flickr.com/services/rest/')
|
||||
.query({
|
||||
api_key: FLICKR_KEY,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class ForecastCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -24,7 +24,7 @@ module.exports = class ForecastCommand extends Command {
|
||||
|
||||
async run(msg, { location }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://query.yahooapis.com/v1/public/yql')
|
||||
.query({
|
||||
// eslint-disable-next-line max-len
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class GelbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -23,7 +23,7 @@ module.exports = class GelbooruCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://gelbooru.com/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { GIPHY_KEY } = process.env;
|
||||
|
||||
module.exports = class GiphyCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class GiphyCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://api.giphy.com/v1/gifs/search')
|
||||
.query({
|
||||
q: query,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten, base64 } = require('../../util/Util');
|
||||
const { GITHUB_USERNAME, GITHUB_PASSWORD } = process.env;
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class GithubCommand extends Command {
|
||||
|
||||
async run(msg, { author, repository }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://api.github.com/repos/${author}/${repository}`)
|
||||
.set({ Authorization: `Basic ${base64(`${GITHUB_USERNAME}:${GITHUB_PASSWORD}`)}` });
|
||||
const embed = new MessageEmbed()
|
||||
@@ -50,7 +50,7 @@ module.exports = class GithubCommand extends Command {
|
||||
.addField('❯ Modification Date', new Date(body.updated_at).toDateString(), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.statusCode === 404) return msg.say('Could not find any results.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class GoogleAutofillCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -21,13 +21,13 @@ module.exports = class GoogleAutofillCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('https://suggestqueries.google.com/complete/search')
|
||||
.query({
|
||||
client: 'firefox',
|
||||
q: query
|
||||
});
|
||||
const data = JSON.parse(raw.toString())[1];
|
||||
const data = JSON.parse(text)[1];
|
||||
if (!data.length) return msg.say('Could not find any results.');
|
||||
return msg.say(data.join('\n'));
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class GoogleBookCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://www.googleapis.com/books/v1/volumes')
|
||||
.query({
|
||||
apiKey: GOOGLE_KEY,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { GOOGLE_KEY, CUSTOM_SEARCH_ID } = process.env;
|
||||
|
||||
module.exports = class GoogleCommand extends Command {
|
||||
@@ -26,7 +26,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://www.googleapis.com/customsearch/v1')
|
||||
.query({
|
||||
key: GOOGLE_KEY,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { hash } = require('../../util/Util');
|
||||
|
||||
module.exports = class GravatarCommand extends Command {
|
||||
@@ -24,7 +24,7 @@ module.exports = class GravatarCommand extends Command {
|
||||
async run(msg, { email }) {
|
||||
const emailHash = hash(email, 'md5');
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://www.gravatar.com/avatar/${emailHash}`)
|
||||
.query({
|
||||
size: 500,
|
||||
@@ -33,7 +33,7 @@ module.exports = class GravatarCommand extends Command {
|
||||
});
|
||||
return msg.say({ files: [{ attachment: body, name: `${emailHash}.jpg` }] });
|
||||
} catch (err) {
|
||||
if (err.statusCode === 404) return msg.say('Could not find any results.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class HttpCatCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -21,7 +21,7 @@ module.exports = class HttpCatCommand extends Command {
|
||||
|
||||
async run(msg, { code }) {
|
||||
try {
|
||||
const { body, headers } = await snekfetch.get(`https://http.cat/${code}.jpg`);
|
||||
const { body, headers } = await request.get(`https://http.cat/${code}.jpg`);
|
||||
if (headers['content-type'] === 'text/html') return msg.say('Could not find any results.');
|
||||
return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] });
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { IMGUR_KEY } = process.env;
|
||||
|
||||
module.exports = class ImgurCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class ImgurCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://api.imgur.com/3/gallery/search')
|
||||
.query({ q: query })
|
||||
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class ItunesCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -30,7 +30,7 @@ module.exports = class ItunesCommand extends Command {
|
||||
|
||||
async run(msg, { country, query }) {
|
||||
try {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('https://itunes.apple.com/search')
|
||||
.query({
|
||||
term: query,
|
||||
@@ -40,7 +40,7 @@ module.exports = class ItunesCommand extends Command {
|
||||
explicit: msg.channel.nsfw ? 'yes' : 'no',
|
||||
country
|
||||
});
|
||||
const body = JSON.parse(raw.toString());
|
||||
const body = JSON.parse(text);
|
||||
if (!body.results.length) return msg.say('Could not find any results.');
|
||||
const data = body.results[0];
|
||||
const embed = new MessageEmbed()
|
||||
@@ -55,7 +55,7 @@ module.exports = class ItunesCommand extends Command {
|
||||
.addField('❯ Genre', data.primaryGenreName, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.statusCode === 400) {
|
||||
if (err.status === 400) {
|
||||
return msg.reply('Invalid country code. Refer to <https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes>.');
|
||||
}
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class JishoCommand extends Command {
|
||||
@@ -22,7 +22,7 @@ module.exports = class JishoCommand extends Command {
|
||||
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('http://jisho.org/api/v1/search/words')
|
||||
.query({ keyword: word });
|
||||
if (!body.data.length) return msg.say('Could not find any results.');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class KickstarterCommand extends Command {
|
||||
@@ -24,7 +24,7 @@ module.exports = class KickstarterCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://www.kickstarter.com/projects/search.json')
|
||||
.query({
|
||||
search: '',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class KonachanCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -23,7 +23,7 @@ module.exports = class KonachanCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://konachan.net/post.json')
|
||||
.query({
|
||||
tags: `${query} order:random`,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { RIOT_KEY } = process.env;
|
||||
const buttons = ['Q', 'W', 'E', 'R'];
|
||||
|
||||
@@ -66,7 +66,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
|
||||
}
|
||||
|
||||
async fetchVersion() {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://na1.api.riotgames.com/lol/static-data/v3/versions')
|
||||
.query({ api_key: RIOT_KEY });
|
||||
[this.version] = body;
|
||||
@@ -76,7 +76,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
|
||||
|
||||
async fetchChampions() {
|
||||
if (this.champions && this.champions.version === this.version) return this.champions;
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion.json`);
|
||||
this.champions = body;
|
||||
return body;
|
||||
@@ -87,7 +87,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
|
||||
const name = Object.keys(champions.data).find(key => key.toLowerCase() === champion);
|
||||
if (!name) return null;
|
||||
const { id } = champions.data[name];
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion/${id}.json`);
|
||||
return body.data[id];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class MapCommand extends Command {
|
||||
@@ -35,7 +35,7 @@ module.exports = class MapCommand extends Command {
|
||||
|
||||
async run(msg, { zoom, location }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: location,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class MDNCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -24,7 +24,7 @@ module.exports = class MDNCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://developer.mozilla.org/en-US/search.json')
|
||||
.query({
|
||||
q: query,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { parseString } = require('xml2js');
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(parseString);
|
||||
@@ -28,11 +28,11 @@ module.exports = class MyAnimeListAnimeCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('https://myanimelist.net/api/anime/search.xml')
|
||||
.query({ q: query })
|
||||
.set({ Authorization: `Basic ${base64(`${MAL_USERNAME}:${MAL_PASSWORD}`)}` });
|
||||
const body = await xml(raw.toString());
|
||||
const body = await xml(text);
|
||||
const data = body.anime.entry[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { parseString } = require('xml2js');
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(parseString);
|
||||
@@ -28,11 +28,11 @@ module.exports = class MyAnimeListMangaCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('https://myanimelist.net/api/manga/search.xml')
|
||||
.query({ q: query })
|
||||
.set({ Authorization: `Basic ${base64(`${MAL_USERNAME}:${MAL_PASSWORD}`)}` });
|
||||
const body = await xml(raw.toString());
|
||||
const body = await xml(text);
|
||||
const data = body.manga.entry[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class NASACommand extends Command {
|
||||
@@ -23,7 +23,7 @@ module.exports = class NASACommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { body } = await request
|
||||
.get('https://images-api.nasa.gov/search')
|
||||
.query({
|
||||
q: query,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const request = require('superagent');
|
||||
const { list } = require('../../util/Util');
|
||||
const moods = {
|
||||
happy: 1,
|
||||
@@ -40,14 +40,14 @@ module.exports = class NeopetCommand extends Command {
|
||||
|
||||
async run(msg, { pet, mood }) {
|
||||
try {
|
||||
const { raw } = await snekfetch
|
||||
const { text } = await request
|
||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||
.query({
|
||||
name: pet,
|
||||
size: 5,
|
||||
mood: moods[mood]
|
||||
});
|
||||
const link = raw.toString().match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/);
|
||||
const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/);
|
||||
if (!link) return msg.say('Could not find any results.');
|
||||
return msg.say(link[0]);
|
||||
} catch (err) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user