From 8226f421af88298af122cf1548d2fdfed362ea58 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 11 Apr 2018 01:08:45 +0000 Subject: [PATCH] Shields.io badge, hi --- README.md | 4 ++- commands/image-edit/shields-io-badge.js | 45 +++++++++++++++++++++++++ commands/single/hi.js | 23 +++++++++++++ package.json | 2 +- 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 commands/image-edit/shields-io-badge.js create mode 100644 commands/single/hi.js diff --git a/README.md b/README.md index d582e5bb..1592c002 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Xiao is a Discord bot coded in JavaScript with 300 commands, she is one of the most feature-filled bots out there, and formerly served over 10,000 servers with a uniquely devoted fanbase. -## Commands (302) +## Commands (304) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -97,6 +97,7 @@ served over 10,000 servers with a uniquely devoted fanbase. * **eat-pant**: Eat pant. * **give-flower**: Gives Xiao Pai a flower. * **hello-world**: Hello world. +* **hi**: Hello. * **isnt-joke**: Isn't joke... * **its-joke**: It's joke! * **lenny**: Responds with the lenny face. @@ -241,6 +242,7 @@ served over 10,000 servers with a uniquely devoted fanbase. * **pokemon-fusion**: Fuses two Generation I Pokémon together. * **robohash**: Creates a robot based on the text you provide. * **sepia**: Draws an image or a user's avatar in sepia. +* **shields-io-badge**: Creates a badge from shields.io. * **silhouette**: Draws a silhouette of an image or a user's avatar. * **tint**: Draws an image or a user's avatar but tinted a specific color. diff --git a/commands/image-edit/shields-io-badge.js b/commands/image-edit/shields-io-badge.js new file mode 100644 index 00000000..48a14cc4 --- /dev/null +++ b/commands/image-edit/shields-io-badge.js @@ -0,0 +1,45 @@ +const { Command } = require('discord.js-commando'); +const snekfetch = require('snekfetch'); + +module.exports = class ShieldsIoBadgeCommand extends Command { + constructor(client) { + super(client, { + name: 'shields-io-badge', + aliases: ['shields-io', 'img-shields-io'], + group: 'image-edit', + memberName: 'shields-io-badge', + description: 'Creates a badge from shields.io.', + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'subject', + prompt: 'What is the subject of the badge?', + type: 'string', + parse: subject => encodeURIComponent(subject.replace(/-/g, '--').replace(/_/g, '__')) + }, + { + key: 'status', + prompt: 'What is the status of the badge?', + type: 'string', + parse: status => encodeURIComponent(status.replace(/-/g, '--').replace(/_/g, '__')) + }, + { + key: 'color', + prompt: 'What is the color of the badge?', + type: 'string', + default: 'brightgreen' + } + ] + }); + } + + async run(msg, { subject, status, color }) { + try { + const { body, headers } = await snekfetch.get(`https://img.shields.io/badge/${subject}-${status}-${color}.png`); + if (headers['Content-Type'] !== 'image/png') return msg.reply('Could not create the badge...'); + return msg.say({ files: [{ attachment: body, name: 'badge.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/commands/single/hi.js b/commands/single/hi.js new file mode 100644 index 00000000..55b106d7 --- /dev/null +++ b/commands/single/hi.js @@ -0,0 +1,23 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class HelloWorldCommand extends Command { + constructor(client) { + super(client, { + name: 'hi', + aliases: ['hello', 'hey', 'hoi', 'hola'], + group: 'single', + memberName: 'hi', + description: 'Hello.', + clientPermissions: ['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'] + }); + } + + async run(msg) { + try { + await msg.react('👋'); + return null; + } catch (err) { + return msg.reply('Hi there!'); + } + } +}; diff --git a/package.json b/package.json index ef8736a3..3abe0c67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "71.1.0", + "version": "71.2.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {