mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Gun Command
This commit is contained in:
@@ -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 |
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "116.20.1",
|
||||
"version": "116.21.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user