mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Kyon Gun Command
This commit is contained in:
@@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
7. Run `npm i -g pm2` to install PM2.
|
||||
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
||||
|
||||
## Commands (332)
|
||||
## Commands (333)
|
||||
### Utility:
|
||||
|
||||
* **eval:** Executes JavaScript code.
|
||||
@@ -296,6 +296,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
* **ifunny:** Draws an image with the iFunny logo.
|
||||
* **illegal:** Makes President Trump make your text illegal.
|
||||
* **invert:** Draws an image or a user's avatar but inverted.
|
||||
* **kyon-gun:** Draws an image or a user's avatar behind Kyon shooting a gun.
|
||||
* **meme-gen:** Sends a meme with the text and background of your choice.
|
||||
* **minecraft-skin:** Sends the Minecraft skin for a user.
|
||||
* **needs-more-jpeg:** Draws an image or a user's avatar as a low quality JPEG.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
@@ -0,0 +1,48 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class KyonGunCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'kyon-gun',
|
||||
aliases: ['kyon-snapped'],
|
||||
group: 'image-edit',
|
||||
memberName: 'kyon-gun',
|
||||
description: 'Draws an image or a user\'s avatar behind Kyon shooting a gun.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
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', 'kyon-gun.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillRect(0, 0, base.width, base.height);
|
||||
const ratio = data.width / data.height;
|
||||
const width = Math.round(base.height * ratio);
|
||||
ctx.drawImage(data, (base.width / 2) - (width / 2), 0, width, base.height);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'kyon-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": "98.2.0",
|
||||
"version": "98.3.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user