mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 00:12:32 +02:00
Approved and Rejected
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 286 KiB |
@@ -0,0 +1,48 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class ApprovedCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'approved',
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'approved',
|
||||||
|
description: 'Draws an "approved" stamp over a user\'s avatar.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 30
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
|
type: 'user',
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, args) {
|
||||||
|
const user = args.user || msg.author;
|
||||||
|
const avatarURL = user.displayAvatarURL({
|
||||||
|
format: 'png',
|
||||||
|
size: 256
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const canvas = createCanvas(256, 256);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'approved.png'));
|
||||||
|
const { body } = await snekfetch.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
ctx.drawImage(avatar, 0, 0, 256, 256);
|
||||||
|
ctx.drawImage(base, 0, 0, 256, 256);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'approved.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, the image generation failed: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class RejctedCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'rejected',
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'rejected',
|
||||||
|
description: 'Draws a "rejected" stamp over a user\'s avatar.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 30
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
|
type: 'user',
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, args) {
|
||||||
|
const user = args.user || msg.author;
|
||||||
|
const avatarURL = user.displayAvatarURL({
|
||||||
|
format: 'png',
|
||||||
|
size: 256
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const canvas = createCanvas(256, 256);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rejected.png'));
|
||||||
|
const { body } = await snekfetch.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
ctx.drawImage(avatar, 0, 0, 256, 256);
|
||||||
|
ctx.drawImage(base, 0, 0, 256, 256);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rejected.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, the image generation failed: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "27.1.6",
|
"version": "27.2.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user