-
Notifications
You must be signed in to change notification settings - Fork 121
/
index.js
180 lines (123 loc) · 5.12 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
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
});
const cooldown = new Set();
const cdseconds = 1;
// This code is made by Atreya#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 => {
const channel = db.get(`welcome_${member.guild.id}`);
const text = db.get(`desc_${member.guild.id}`)
const img = db.get(`image_${member.guild.id}`)
const nail = db.get(`thumbnail_${member.guild.id}`)
if (channel === null) {
return;
}
// This code is made by Atreya#2401
const 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);
const tnail = nail.replace(/`?\?useravatar`?/g, member.user.displayAvatarURL({ dynamic: true })).replace(/`?\?serveravatar`?/g, member.guild.iconURL({ dynamic: true }))
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 => {
const chx = db.get(`welcomeimg_${member.guild.id}`);
if (chx === null) {
return;
}
const link = links.link[Math.floor((Math.random() * links.link.length))];
const img = await canvas.loadImage(`${link}`);
const userPfp = await resolveImage(member.user.displayAvatarURL({
format: "jpg",
size: 1024
}))
const 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(`
|-----------------------------------------|
| Information |
|-----------------------------------------|
|• Alive: 24/7 |
|-----------------------------------------|
|• Author: Atreya#2401 |
|-----------------------------------------|
|• Server: https://discord.gg/gU7XAxTpX5 |
|-----------------------------------------|
|• Github: https://github.com/diwasatreya |
|-----------------------------------------|
|• License: Apache License 2.0 |
|-----------------------------------------|
`)).listen(3000) //Don't 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);