From b3ec136124be12a5a1aef4c3337e4f0cb2c3f1da Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 27 Apr 2017 12:22:43 +0000 Subject: [PATCH] random.cat API --- README.md | 2 +- commands/avataredit/3000years.js | 1 - commands/randomimg/cat.js | 13 +++++++++---- commands/randomimg/cats.json | 22 ---------------------- commands/util/info.js | 2 +- html/carbondesc.html | 1 + html/discordbots.html | 1 + package.json | 2 +- 8 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 commands/randomimg/cats.json diff --git a/README.md b/README.md index 4e135527..5c28c6b6 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can join the home server with [this link](https://discord.gg/fqQF8mc). [discord.js](https://discord.js.org/#/), [commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/) ## APIs -[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [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 Static Maps](https://developers.google.com/maps/documentation/static-maps/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [rrrather](http://www.rrrather.com/botapi), [SoundCloud](https://developers.soundcloud.com/) +[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [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 Static Maps](https://developers.google.com/maps/documentation/static-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/) ## Self-Hosting You can Self-Host the bot easily, provided you have API keys and a Discord Bot Token. [Node.js](https://nodejs.org/en/) is also required, with at least version 7.6.0 recommended. diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index 60e2338d..3c86129b 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -1,6 +1,5 @@ const { Command } = require('discord.js-commando'); const Jimp = require('jimp'); -const request = require('superagent'); module.exports = class YearsCommand extends Command { constructor(client) { diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index 8153cec4..79208e48 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const cats = require('./cats'); +const request = require('superagent'); module.exports = class CatCommand extends Command { constructor(client) { @@ -14,11 +14,16 @@ module.exports = class CatCommand extends Command { }); } - run(message) { + async run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); - const cat = cats[Math.floor(Math.random() * cats.length)]; - return message.channel.send({files: [cat]}); + try { + const { body } = await request + .get('http://random.cat/meow'); + return message.channel.send({files: [body.file]}); + } catch (err) { + return message.say('An Unknown Error Occurred.'); + } } }; diff --git a/commands/randomimg/cats.json b/commands/randomimg/cats.json deleted file mode 100644 index 3afea1a7..00000000 --- a/commands/randomimg/cats.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - "https://i.imgur.com/BYIsrcy.jpg", - "https://i.imgur.com/4huevNv.jpg", - "https://i.imgur.com/I52wMLL.jpg", - "https://i.imgur.com/51xZFRg.jpg", - "https://i.imgur.com/4CfKp58.jpg", - "https://i.imgur.com/vNU99Ix.jpg", - "https://i.imgur.com/Fvru0x5.jpg", - "https://i.imgur.com/pBbf7gu.jpg", - "https://i.imgur.com/A7UjE8I.jpg", - "https://i.imgur.com/qfGSFCa.jpg", - "https://i.imgur.com/e3isfmE.jpg", - "https://i.imgur.com/kEDeoUT.jpg", - "https://i.imgur.com/pta9FML.jpg", - "https://i.imgur.com/HKhVeiV.jpg", - "https://i.imgur.com/1qpQesN.jpg", - "https://i.imgur.com/lEeoU0b.jpg", - "https://i.imgur.com/VINBpuw.jpg", - "https://i.imgur.com/1dp1koX.jpg", - "https://i.imgur.com/N586OTx.jpg", - "https://i.imgur.com/0T1ykQI.jpg" -] diff --git a/commands/util/info.js b/commands/util/info.js index 2bef277f..80491b12 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -46,7 +46,7 @@ module.exports = class InfoCommand extends Command { .addField('Modules', '[commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)') .addField('APIs', - '[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [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/), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [rrrather](http://www.rrrather.com/botapi), [SoundCloud](https://developers.soundcloud.com/)'); + '[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [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/), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-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/)'); return message.embed(embed); } }; diff --git a/html/carbondesc.html b/html/carbondesc.html index 1a137e64..a50a74c6 100644 --- a/html/carbondesc.html +++ b/html/carbondesc.html @@ -47,6 +47,7 @@
  • Strawpoll
  • rrrather
  • SoundCloud
  • +
  • random.cat
  • Information

    Information

    diff --git a/package.json b/package.json index 6280822a..8969351b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "16.2.0", + "version": "16.2.1", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {