forked from diwasatreya/Welcome-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
181 lines (124 loc) · 5.15 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
const { prefix, developerID } = require("./config.json")
const { config } = require("dotenv");
const db =require("quick.db");
const welc = require("image-cord")
const moment = require("moment");
const Discord = require('discord.js')
const fetch = require("node-fetch");
const express = require('express')
const app = express()
const { Canvas, resolveImage } = require('canvas-constructor');
const canvas = require('canvas')
const { Client, MessageEmbed } = require('discord.js');
const client = new Discord.Client({
disableEveryone: false
});
let cooldown = new Set();
let cdseconds = 1; // cooldown time
// This code is made by Supreme#2401
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
["command"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
process.on('UnhandledRejection', console.error);
client.on("message", async message => {
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
if(cooldown.has(message.author.id)){
return message.channel.send(`**${message.author.username}** wait \`10\` seconds to use this command!`)
}
cooldown.add(message.author.id);
setTimeout(() => {
cooldown.delete(message.author.id)}, cdseconds * 1000)
if (!message.member)
message.member = message.guild.fetchMember(message);
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command = client.commands.get(cmd);
if (!command) command = client.commands.get(client.aliases.get(cmd));
if (command) command.run(client, message, args);
});
const { registerFont } = require('canvas');
registerFont('./fonts/Vampire Wars.ttf', { family: 'Vampire Wars' });
client.on("guildMemberAdd", async member => {
let channel = db.get(`welcome_${member.guild.id}`);
let text = db.get(`desc_${member.guild.id}`)
let img = db.get(`image_${member.guild.id}`)
let nail = db.get(`thumbnail_${member.guild.id}`)
if (channel === null) {
return;
}
// This code is made by Supreme#2401
let mes = text.replace(/`?\?user`?/g, member.user.username).replace(/`?\?server`?/g, member.guild.name).replace(/`?\?tag`?/g, member.user.tag).replace(/`?\?mention`?/g, `<@${member.user.id}>`).replace(/`?\?rank`?/g, member.guild.members.cache.size);
let tnail = nail.replace(/`?\?useravatar`?/g, member.user.displayAvatarURL({ dynamic: true })).replace(/`?\?serveravatar`?/g, member.guild.iconURL({ dynamic: true }))
// This code is made by Supreme#2401
const embed = new Discord.MessageEmbed()
.setTitle(`Welcome to ${member.guild.name}`)
.setDescription(`${mes}`)
.setImage(img)
.setThumbnail(tnail)
.setColor("RANDOM")
client.channels.cache.get(channel).send(embed)
});
const links = require('./JSON/link.json')
client.on("guildMemberAdd", async member => {
let chx = db.get(`welcomeimg_${member.guild.id}`);
if (chx === null) {
return;
}
let link = links.link[Math.floor((Math.random() * links.link.length))];
const img = await canvas.loadImage(`${link}`);
let userPfp = await resolveImage(member.user.displayAvatarURL({
format: "jpg",
size: 1024
}))
let image = new Canvas(6912, 3456)
.printImage(img, 0, 0, 6912, 3456)
.setColor(`#FFFFFF`)
.setTextFont('215px Quicksand-SemiBold')
.setTextAlign("center")
.printWrappedText(moment(member.user.createdAt).format("MMMM d, YYYY"), 2655, 1980)
.setTextAlign("center")
.setTextFont('215px Quicksand-SemiBold')
.printWrappedText(member.user.tag, 1920, 1355)
.printWrappedText(`${member.guild.members.cache.size}th member`, 2180, 2600)
.setColor(`#FFFFFF`)
.setTextAlign("center")
.setTextFont('250px Quicksand-SemiBold')
.setTextAlign("center")
.printWrappedText(member.guild.name, 1900, 3100)
.printCircularImage(userPfp, 5260, 1714, 1210, 1120)
.toBuffer();
client.channels.cache.get(chx).send(new Discord.MessageAttachment((await image), "image.png"));
});
// Do not change anything here
require('http').createServer((req, res) => res.end(`
|-----------------------------------------|
| Informations |
|-----------------------------------------|
|• Alive: 24/7 |
|-----------------------------------------|
|• Author: Supreme#2401 |
|-----------------------------------------|
|• Server: https://discord.gg/gU7XAxTpX5 |
|-----------------------------------------|
|• Github: https://github.com/diwasatreya |
|-----------------------------------------|
|• License: Apache License 2.0 |
|-----------------------------------------|
`)).listen(3000) //Dont remove this
client.on("ready", () => {
client.user.setStatus("dnd"); // You can change it to online, dnd, idle
console.log(`Successfully logined as ${client.user.tag} `)
});
// For Watching Status
// client.on("ready", () => {
// client.user.setActivity(`Chilling with owner`, { type: "STREAMING",
// url: "https://www.twitch.tv/nocopyrightsounds"})});
client.login(process.env.TOKEN);