SHARE
TWEET

Command

a guest Apr 25th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Command } = require('discord-akairo');
  2. const { createCanvas, loadImage } = require('canvas');
  3. const request = require('node-superfetch');
  4.  
  5. module.exports = class ThreeThousandYearsCommand extends Command {
  6.     constructor() {
  7.         super('3000-years', {
  8.             aliases: ['3ky', '3k-years', '3000-years'],
  9.             category: 'Fun',
  10.             description: 'Draws a user\'s avatar over Pok√©mon\'s "It\'s been 3000 years" meme.',
  11.             cooldown: 10000,
  12.       ratelimit: 1,
  13.             clientPermissions: ['ATTACH_FILES'],
  14.             args: [
  15.                 {
  16.                     key: 'user',
  17.                     prompt: 'Which user would you like to edit the avatar of?',
  18.                     type: 'user',
  19.                     default: msg => msg.author
  20.                 }
  21.             ]
  22.         });
  23.     }
  24.  
  25.     async run(msg, { user }) {
  26.         const avatarURL = user.displayAvatarURL.endsWith(".webp") ? user.displayAvatarURL.slice(0, -5) + ".png" : user.displayAvatarURL;
  27.         try {
  28.             const base = await loadImage('../assets/3000-years.png');
  29.             const { body } = await request.get(avatarURL);
  30.             const avatar = await loadImage(body);
  31.             const canvas = createCanvas(base.width, base.height);
  32.             const ctx = canvas.getContext('2d');
  33.             ctx.drawImage(base, 0, 0);
  34.             ctx.drawImage(avatar, 461, 127, 200, 200);
  35.             return msg.say({ files: [{ attachment: canvas.toBuffer(), name: '3000-years.png' }] });
  36.         } catch (err) {
  37.             return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
  38.         }
  39.     }
  40. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top