Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.run = async (client, msg, args) => {
let user = msg.mentions.users.first() || client.users.get(args[0]);
if (!user) user = msg.author;
try {
const paintMess = await msg.channel.send("🖌️ Painting...");
const png = user.avatarURL.replace(/\.gif/g, ".png");
const { body } = await client.snek.get(png);
const avatar = await loadImage(body);
let newSepia = new Canvas(avatar.width, avatar.height)
.addRect(0, 0, avatar.width, avatar.height)
.setColor("#000000")
.addImage(body, 0, 0, avatar.width, avatar.height);
newSepia = sepia(newSepia)
.toBuffer();
await paintMess.delete();
return msg.channel.send(new Attachment(newSepia, "sepia.png"));
} catch (e) {
return msg.channel.send(`Oh no an error occured :( \`${e.message}\` try again later`);
}
};