diff --git a/README.md b/README.md index 7448df20..f8aa4eb4 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 477 +Total: 478 ### Utility: @@ -568,6 +568,7 @@ Total: 477 * **glass-shatter:** Draws an image or a user's avatar with a glass shatter in front of it. * **glitch:** Draws an image or a user's avatar but glitched. * **greyscale:** Draws an image or a user's avatar in greyscale. +* **gun:** Draws a gun over an image or a user's avatar. * **highway-sign:** Sends a highway sign sign with the text of your choice. * **hollywood-star:** Sends a Hollywood Walk of Fame star with the name of your choice. * **ifunny:** Draws an image with the iFunny logo. @@ -1165,6 +1166,8 @@ here. * horse-race ([Horse Name Data](https://horses.lovetoknow.com/horse-names/funny-horse-names)) - [LowGif](http://www.lowgif.com/) * fire ([Images](http://www.lowgif.com/43360ebce9150f23.html)) +- [Luxoflux](http://www.luxoflux.com/) + * gun ([Image](https://knowyourmeme.com/memes/hand-pointing-a-gun)) - [Mad Libs](http://www.madlibs.com/) * mad-libs (Original Game) - [Mad:)Takes](https://www.madtakes.com/index.php) @@ -1264,6 +1267,7 @@ here. - [Overtime2005](https://github.com/Overtime2005) * alert (Concept) * dislike (Concept) + * gun (Concept) * hentai (Original Subreddit List) * like (Concept) * pogchamp (Concept) diff --git a/assets/images/gun.png b/assets/images/gun.png new file mode 100644 index 00000000..3c0bcd23 Binary files /dev/null and b/assets/images/gun.png differ diff --git a/commands/edit-image/gun.js b/commands/edit-image/gun.js new file mode 100644 index 00000000..6f1eabec --- /dev/null +++ b/commands/edit-image/gun.js @@ -0,0 +1,60 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); + +module.exports = class GunCommand extends Command { + constructor(client) { + super(client, { + name: 'gun', + group: 'edit-image', + memberName: 'gun', + description: 'Draws a gun over an image or a user\'s avatar.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + }, + { + name: 'Luxoflux', + url: 'http://www.luxoflux.com/', + reason: 'Image', + reasonURL: 'https://knowyourmeme.com/memes/hand-pointing-a-gun' + } + ], + args: [ + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) + } + ] + }); + } + + async run(msg, { image }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'gun.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(data.width, data.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(data, 0, 0); + const ratio = (data.height / 2) / base.height; + const width = base.width * ratio; + ctx.drawImage(base, data.width - width, data.height - (data.height / 2), width, data.height / 2); + const attachment = canvas.toBuffer(); + if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + return msg.say({ files: [{ attachment, name: 'gun.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 12fa3cf8..4dc16248 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.20.1", + "version": "116.21.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {