diff --git a/README.md b/README.md index 0886c51f..a53809b9 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 414 +Total: 415 ### Utility: @@ -316,6 +316,7 @@ Total: 414 * **know-your-meme:** Searches Know Your Meme for your query. * **league-of-legends:** Responds with information on a League of Legends champion. * **lyrics:** Responds with lyrics to a song. +* **mal-badges:** Responds with a MyAnimeList user's mal-badges badge. * **manga:** Searches AniList for your query, getting manga results. * **map:** Responds with a map of a specific location. * **mayo-clinic:** Searches Mayo Clinic for your query. @@ -951,6 +952,8 @@ here. * mad-libs (Original Game) - [Mad:)Takes](https://www.madtakes.com/index.php) * mad-libs (Mad Libs Data) +- [mal-badges](http://www.mal-badges.net/) + * mal-badges (API) - [MangaGamer.com](https://www.mangagamer.com/) * box-choosing ([Original Translation](https://store.steampowered.com/app/526490/Higurashi_When_They_Cry_Hou__Ch4_Himatsubushi/)) - [Marvelous](http://www.marv.jp/) diff --git a/commands/search/mal-badges.js b/commands/search/mal-badges.js new file mode 100644 index 00000000..52b9d074 --- /dev/null +++ b/commands/search/mal-badges.js @@ -0,0 +1,48 @@ +const Command = require('../../structures/Command'); +const { MessageEmbed } = require('discord.js'); +const request = require('node-superfetch'); + +module.exports = class MalBadgesCommand extends Command { + constructor(client) { + super(client, { + name: 'mal-badges', + aliases: ['my-anime-list-badges', 'mal-badge', 'my-anime-list-badge'], + group: 'search', + memberName: 'mal-badges', + description: 'Responds with a MyAnimeList user\'s mal-badges badge.', + credit: [ + { + name: 'mal-badges', + url: 'http://www.mal-badges.net/', + reason: 'API' + } + ], + args: [ + { + key: 'user', + prompt: 'What user would you like to get the badge of?', + type: 'string', + parse: user => encodeURIComponent(user) + } + ] + }); + } + + async run(msg, { user }) { + try { + const { body } = await request.get(`http://www.mal-badges.net/users/${user}/badge`); + const embed = new MessageEmbed() + .attachFiles([{ attachment: body, name: 'badge.png'} ]) + .setTitle(user) + .setImage('attachment://badge.png') + .setURL(`http://www.mal-badges.net/users/${user}`) + .setColor(0x00ADB5); + return msg.embed(embed); + } catch (err) { + if (err.status === 404 || err.status === 500) { + return msg.say(`Could not find any results. Try updating at .`); + } + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 8a426d3a..ff1213f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.6.3", + "version": "114.7.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {