-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbyebye.js
More file actions
88 lines (67 loc) · 2.32 KB
/
Copy pathbyebye.js
File metadata and controls
88 lines (67 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const discord = require('discord.js');
const Canvas = require('canvas');
const path = require('path');
const editJsonFile = require('edit-json-file');
const { isDate } = require('util');
const file = editJsonFile(path.join(__dirname, '/config.json'));
Canvas.registerFont(path.join(__dirname, '/NotoSans-Regular.ttf'), {
family: 'fontfamily',
});
Canvas.registerFont(path.join(__dirname, '/aileron.light-italic.otf'), {
family: 'italic fontfamily',
});
module.exports = (client) => {
client.on('guildMemberRemove', async (member) => {
const channel = member.guild.channels.cache.find(
(ch) => ch.name === 'welcome'
);
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const context = canvas.getContext('2d');
const background = await Canvas.loadImage('./background.png');
let x = 0;
let y = 0;
context.drawImage(background, x, y, canvas.width, canvas.height);
context.fillStyle = '#ffffff';
context.font = '30px fontfamily';
let text = `ByeBye ${member.user.tag}`;
x = canvas.width / 2 - context.measureText(text).width / 2;
context.fillText(text, x, 60 + 128);
context.font = '27px italic fontfamily';
text = `Spread the word: Javascript Bad`;
x = canvas.width / 2 - context.measureText(text).width / 2;
context.fillText(text, x, 100 + 128);
const pfp = await Canvas.loadImage(
member.user.displayAvatarURL({ format: 'png' })
);
x = canvas.width / 2 - 128 / 2;
y = 25;
// Pick up the pen
context.beginPath();
// Start the arc to form a circle
context.arc(350, 89, 64, 0, Math.PI * 2, true);
context.lineWidth = 5;
context.strokeStyle = 'white';
context.stroke();
// Put the pen down
context.closePath();
// Clip off the region you drew on
context.clip();
context.drawImage(pfp, x, y, 128, 128);
const attachment = new discord.MessageAttachment(
canvas.toBuffer(),
'welcome-image.png'
);
// New memeber add
let embed = new discord.MessageEmbed();
embed.setTitle('Bye bye!');
embed.setFooter('💫⭐💫');
//embed.attachFiles(attachment).setImage('attachment://welcome-image.png');
embed.setImage('attachment://welcome-image.png');
channel.send({embeds: [embed], files: [attachment]});
// let role = member.guild.roles.cache.find(
// (role) => role.name === 'Participants'
// );
// if (role) member.roles.add(role);
});
};