-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (63 loc) · 2.41 KB
/
index.js
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
//const config = require('./config.json')
const { Client, GatewayIntentBits, Events} = require('discord.js');
const {WelcomeCard} = require('./card.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
});
const config={
backgroundImg: process.env.BGIMAGEURL,
token: process.env.TOKEN,
GuildID: process.env.GUILDID,
WelcomeChannel: process.env.W_CHANNEL,
infoChannel: process.env.INFO_CHANNEL,
WelcomeText: process.env.WTEXT,
memberCountText: process.env.MTEXT
}
const wCard = new WelcomeCard({
WelcomeTextFont: "./fonts/NaikaiFont-Bold.ttf",
Titlefont: "./fonts/NotoSansTC-Black.otf",
SubTitleFont: "./fonts/NaikaiFont-Bold.ttf"
})
const bg = config.backgroundImg || 'https://media.discordapp.net/attachments/464402915591979028/1095545854917623848/PSX_20230412_110801.jpg'
client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
client.on(Events.MessageCreate, async message => {
if (message.author.bot) return;
if (!(['KarterLauder#2466','LarsHagrid#2620'].includes(message.author.tag))) return;
if (!message.content.startsWith('w!test1')) return;
const avatar = message.author.displayAvatarURL({ extension: 'png' })
const imagebuffer = await wCard.CreateImageCard(
bg,
avatar,
'welcomeText',
message.author.username,
`MCount: ${message.guild.memberCount}`
)
await message.channel.send({files: [imagebuffer] })
});
client.on(Events.GuildMemberAdd, async member => {
const avatar = member.user.displayAvatarURL({ extension: 'png' })
const imagebuffer = await wCard.CreateImageCard(
bg,
avatar,
`${config.WelcomeText}`,
member.user.username,
`${config.memberCountText}: ${member.guild.memberCount}`
)
const channel = await client.guilds.cache.get(config.GuildID).channels.fetch(config.WelcomeChannel)
await channel.send({files: [imagebuffer] });
const channel2 = await client.guilds.cache.get(config.GuildID).channels.fetch(config.infoChannel)
await channel2.send({content:`<@${member.user.id}>`});
});
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
wCard.LoadFonts().then(
client.login(config.token)
).catch(async (e)=>{
console.log(e)
await sleep(60000)
})