mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Chocolate Milk Command
This commit is contained in:
@@ -136,7 +136,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 423
|
Total: 424
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -465,6 +465,7 @@ Total: 423
|
|||||||
|
|
||||||
* **avatar-fusion:** Draws a a user's avatar over a user's avatar.
|
* **avatar-fusion:** Draws a a user's avatar over a user's avatar.
|
||||||
* **bob-ross:** Draws a user's avatar over Bob Ross' canvas.
|
* **bob-ross:** Draws a user's avatar over Bob Ross' canvas.
|
||||||
|
* **chocolate-milk:** Draws a user's avatar holding chocolate milk.
|
||||||
* **hat:** Draws a hat over a user's avatar.
|
* **hat:** Draws a hat over a user's avatar.
|
||||||
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
|
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
|
||||||
* **hearts:** Draws hearts around a user's avatar.
|
* **hearts:** Draws hearts around a user's avatar.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
@@ -0,0 +1,59 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class ChocolateMilkCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'chocolate-milk',
|
||||||
|
aliases: ['milk', 'sip-milk', 'sip-chocolate-milk', 'choccy', 'sip-choccy'],
|
||||||
|
group: 'edit-avatar',
|
||||||
|
memberName: 'chocolate-milk',
|
||||||
|
description: 'Draws a user\'s avatar holding chocolate milk.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
|
type: 'user',
|
||||||
|
default: msg => msg.author
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'direction',
|
||||||
|
prompt: 'What direction should the avatar face?',
|
||||||
|
type: 'string',
|
||||||
|
oneOf: ['left', 'right'],
|
||||||
|
default: 'left',
|
||||||
|
parse: direction => direction.toLowerCase()
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { user, direction }) {
|
||||||
|
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
|
try {
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'chocolate-milk.png'));
|
||||||
|
const { body } = await request.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
const canvas = createCanvas(base.width, base.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillRect(0, 0, base.width, base.height);
|
||||||
|
if (direction === 'right') {
|
||||||
|
ctx.translate(base.width, 0);
|
||||||
|
ctx.scale(-1, 1);
|
||||||
|
}
|
||||||
|
ctx.drawImage(avatar, 0, 0, 512, 512);
|
||||||
|
if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'chocolate-milk.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "114.14.0",
|
"version": "114.15.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user