Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var welcomef = require('./welcome.json');
- client.on("guildMemberAdd", async member => {
- if (welcomef[member.guild.id].state == true){
- var channel = member.guild.channels.cache.find(con => con.id == welcomef[member.guild.id].welcomechannel)
- if (channel){
- const canvas = Canvas.createCanvas(663-120, 330-60);
- const ctx = canvas.getContext('2d');
- const background = await Canvas.loadImage('./wlcimg.png'); // مسار خلفية صورة
- ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
- ctx.strokeStyle = '#74037b';
- ctx.strokeRect(0, 0, canvas.width, canvas.height);
- ctx.fillStyle = '#000000';
- ctx.font = "30px Arial";
- ctx.fillText(`${member.displayName}`, canvas.width / 2.1, canvas.height / 1.6);
- ctx.beginPath();
- ctx.arc(128, 138, 95, 0, Math.PI * 2, true);
- ctx.closePath();
- ctx.clip();
- const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
- ctx.drawImage(avatar, 28, 38, 200, 200);
- const alpha = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png'); // نفس شيئ صورة الولكم
- channel.send(welcomef[member.guild.id].message+" <@"+member.id+">", alpha);
- }
- }
- });
- var fs = require("fs");
- client.on("message", message =>{
- var args = message.content.split(" ");
- var command = args[0];
- var channelid;
- var mentioned = message.mentions.channels.first();
- if(mentioned){
- channelid = mentioned.id;
- }else{
- channelid = args[1];
- }
- if (!message.guild) return;
- if (command == prefix+"setwelcome"){
- if (!message.guild.member(message.author).hasPermission("ADMINISTRATOR")){
- return message.reply("You can't use this command !")
- }
- if (!channelid){
- return message.reply("Please insert channel id");
- }
- if(!welcomef[message.guild.id]){
- welcomef[message.guild.id] = {
- welcomechannel: channelid,
- state: true,
- message: "Welcome to our server"
- },
- fs.writeFileSync("./welcome.json", JSON.stringify(welcomef , null , 4));
- message.channel.send("setting welcome .")
- }else {
- welcomef[message.guild.id].welcomechannel = channelid;
- fs.writeFileSync("./welcome.json", JSON.stringify(welcomef , null , 4));
- message.channel.send("Updating Done .")
- }
- }
- if (command == prefix+"togglewelcome"){
- if (!message.guild.member(message.author).hasPermission("ADMINISTRATOR")){
- return message.reply("You can't use this command !")
- }
- if(!welcomef[message.guild.id]){
- return message.channel.send("Your server not have a welcome channel, use `"+prefix+"setwelcome` to add.");
- }
- if(welcomef[message.guild.id].state == true){
- welcomef[message.guild.id].state = false;
- fs.writeFileSync("./welcome.json", JSON.stringify(welcomef , null , 4));
- message.channel.send("Toggled off")
- }else{
- welcomef[message.guild.id].state = true;
- fs.writeFileSync("./welcome.json", JSON.stringify(welcomef , null , 4));
- message.channel.send("Toggled on")
- }
- }
- });
- client.on("message",message => {
- var args = message.content.split(" ");
- var command = args[0];
- var welcomemessage = message.content.split(" ").slice(1).join(" ");
- if (command == prefix+"setwelcomemessage"){
- if (!message.guild.member(message.author).hasPermission("ADMINISTRATOR")){
- return message.reply("You can't use this command !")
- }
- if(!welcomef[message.guild.id]){
- return message.channel.send("Your server not have a welcome channel, use `"+prefix+"setwelcome` to add.");
- }
- if (!welcomemessage){
- return message.reply("please insert welcome message");
- }
- welcomef[message.guild.id].message = welcomemessage;
- fs.writeFileSync("./welcome.json", JSON.stringify(welcomef , null , 4));
- message.channel.send("Setting ..")
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement