Approved and Rejected

This commit is contained in:
Daniel Odendahl Jr
2017-07-15 04:05:53 +00:00
parent 341060ca08
commit f3ed03fb9c
5 changed files with 97 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

+48
View File
@@ -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!`);
}
}
};
+48
View File
@@ -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
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "27.1.6",
"version": "27.2.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {