Gun Command

This commit is contained in:
Dragon Fire
2020-06-12 12:03:50 -04:00
parent fe8a4609b8
commit d9c54cfdac
4 changed files with 66 additions and 2 deletions
+5 -1
View File
@@ -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)
Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

+60
View File
@@ -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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.20.1",
"version": "116.21.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {