Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require("fs");
- const Canvas = require('canvas');
- const Discord = require("discord.js");
- const { prefix, token } = require("./config.json");
- const client = new Discord.Client();
- client.commands = new Discord.Collection();
- const commandFiles = fs
- .readdirSync("./commands")
- .filter(file => file.endsWith(".js"));
- for (const file of commandFiles) {
- const command = require(`./commands/${file}`);
- console.log(`Loaded ${file}`);
- client.commands.set(command.name, command);
- }
- client.once("ready", () => {
- console.log(`Verbose is online.`);
- });
- client.login(token);
- client.on("message", message => {
- client.on("guildMemberAdd", member => {
- const channel = member.guild.channels.find(ch => ch.name === 'member-log');
- if (!channel) return;
- const canvas = Canvas.createCanvas(700, 250);
- const ctx = canvas.getContext('2d');
- const background = await Canvas.loadImage('./wallpaper.jpg');
- ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
- ctx.strokeStyle = '#74037b';
- ctx.strokeRect(0, 0, canvas.width, canvas.height);
- ctx.font = '28px sans-serif';
- ctx.fillStyle = '#ffffff';
- ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);
- ctx.font = applyText(canvas, `${member.displayName}!`);
- ctx.fillStyle = '#ffffff';
- ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);
- ctx.beginPath();
- ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
- ctx.closePath();
- ctx.clip();
- const avatar = await Canvas.loadImage(member.user.displayAvatarURL);
- ctx.drawImage(avatar, 25, 25, 200, 200);
- const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png');
- channel.send(`Welcome to the server, ${member}!`, attachment);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement