JaBa/commands/Images/facepalm.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-01-04 02:18:28 +05:00
const Command = require("../../base/Command.js"),
2022-01-13 00:26:23 +05:00
Canvas = require("canvas");
2022-01-04 02:18:28 +05:00
class Facepalm extends Command {
constructor(client) {
super(client, {
name: "facepalm",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: ["palm"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS", "ATTACH_FILES"],
nsfw: false,
ownerOnly: false,
2022-01-13 00:26:23 +05:00
cooldown: 3000
2022-01-04 02:18:28 +05:00
});
}
async run(message, args) {
const user = await this.client.resolveUser(args[0]) || message.author,
m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const canvas = Canvas.createCanvas(632, 357),
ctx = canvas.getContext("2d");
// Draw background for transparent avatar
ctx.fillStyle = "black";
ctx.fillRect(0, 0, 632, 357);
// Draw avatar
const avatar = await Canvas.loadImage(user.displayAvatarURL({
format: "png",
size: 512
}));
ctx.drawImage(avatar, 199, 112, 235, 235);
// Draw layer
const layer = await Canvas.loadImage("./assets/img/facepalm.png");
ctx.drawImage(layer, 0, 0, 632, 357);
m.delete();
message.channel.send({
files: [{
2022-01-07 02:18:26 +05:00
attachment: canvas.toBuffer()
}]
});
2022-01-04 02:18:28 +05:00
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Facepalm;