mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Magik Command
This commit is contained in:
@@ -227,7 +227,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 504
|
||||
Total: 505
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -585,6 +585,7 @@ Total: 504
|
||||
* **ifunny:** Draws an image with the iFunny logo.
|
||||
* **invert:** Draws an image or a user's avatar but inverted.
|
||||
* **jeopardy-question:** Sends a Jeopardy Question with the text of your choice.
|
||||
* **magik:** Draws an image or a user's avatar but with liquid rescale from ImageMagick.
|
||||
* **minecraft-skin:** Sends the Minecraft skin for a user.
|
||||
* **mirror:** Draws an image or a user's avatar but mirrored on the X/Y axis (or both).
|
||||
* **needs-more-jpeg:** Draws an image or a user's avatar as a low quality JPEG.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const gm = require('gm').subClass({ imageMagick: true });
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class MagikCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'magik',
|
||||
aliases: ['magick', 'liquid-rescale'],
|
||||
group: 'edit-image',
|
||||
memberName: 'magik',
|
||||
description: 'Draws an image or a user\'s avatar but with liquid rescale from ImageMagick.',
|
||||
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 { body } = await request.get(image);
|
||||
const magik = gm(body);
|
||||
gm.out('-liquid-rescale 75%x75%');
|
||||
gm.implode(0.25);
|
||||
const attachment = await this.toBuffer(gm);
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'magik.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
toBuffer(gm) {
|
||||
return new Promise((res, rej) => {
|
||||
gm.toBuffer('PNG', (err, buffer) => {
|
||||
if (err) return rej(err);
|
||||
return res(buffer);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
+7
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "117.0.0",
|
||||
"version": "117.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
@@ -40,27 +40,28 @@
|
||||
"cloc": "^2.5.1",
|
||||
"common-tags": "^1.8.0",
|
||||
"custom-translate": "^2.2.8",
|
||||
"didyoumean2": "^4.0.0",
|
||||
"didyoumean2": "^4.1.0",
|
||||
"discord.js": "^12.2.0",
|
||||
"discord.js-commando": "github:discordjs/Commando",
|
||||
"dotenv": "^8.2.0",
|
||||
"gifencoder": "^2.0.1",
|
||||
"mathjs": "^7.0.1",
|
||||
"moment": "^2.26.0",
|
||||
"gm": "^1.23.1",
|
||||
"mathjs": "^7.0.2",
|
||||
"moment": "^2.27.0",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
"moment-timezone": "^0.5.31",
|
||||
"node-superfetch": "^0.1.10",
|
||||
"pokersolver": "^2.1.3",
|
||||
"random-js": "^2.1.0",
|
||||
"rss-parser": "^3.8.0",
|
||||
"winston": "^3.2.1"
|
||||
"winston": "^3.3.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.2.0",
|
||||
"eslint": "^7.3.1",
|
||||
"eslint-config-amber": "^2.0.3",
|
||||
"eslint-plugin-json": "^2.1.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user