const express = require("express");
const app = express();
app.listen(() => console.log(`Bot Is Ready`));
app.use('/ping', (req, res) => {
res.send(new Date());
});
const Discord = require('discord.js');
const fs = require("fs");
const client = new Discord.Client({intents: 32767});
const { MessageAttachment } = require('discord.js');
const Canvas = require("canvas");
const { inviteTracker } = require("discord-inviter")
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on('guildMemberAdd', async (member, inviter, invite) => {
var x = member.guild.channels.cache.get("1020101321937911918")
const background = await Canvas.loadImage("wallpaper.png");
const canvas = Canvas.createCanvas(500, 357);
const ctx = canvas.getContext('2d');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
let text = member.displayName;
if(text.length > 13) {
text = text.slice(0, 13) + "...";
}
ctx.font = 'bold 30px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.textAlign = "center"
ctx.fillText(text, 167, 300);
ctx.beginPath();
ctx.arc(165, 163, 105, 0, Math.PI * 2, false);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'png', size: 512 }));
ctx.drawImage(avatar, 60.00, 58.00, 210.99999999999997, 210.99999999999997);
const attachment = new Discord.MessageAttachment(canvas.toBuffer());
await x.send({files: [attachment]})
});
tracker = new inviteTracker(client)
tracker.on("guildMemberAdd", async (member, inviter, invite) => {
try {
let sleep = async (ms) => await new Promise(r => setTimeout(r,ms));
const ch = member.guild.channels.cache.get("1020101321937911918")
await sleep(500)
await ch.send({ content: `**Welcome To AsooL** <@${member.user.id}>` })
} catch (err) {
console.log(err)
}
})
client.login("token");