-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
187 lines (128 loc) · 4.67 KB
/
server.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
182
183
184
185
186
187
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
require("dotenv").config();//Loading .env
const { default_prefix } = require("./config.json")
const { config } = require("dotenv");
const fetch = require("node-fetch");
const db =require("quick.db");
const moment = require("moment");
const { CanvasSenpai } = require("canvas-senpai")
const canva = new CanvasSenpai();
const discord = require("discord.js");
const client = new discord.Client({
disableEveryone: false
});
const yts = require('yt-search')
client.queue = new Map();
client.vote = new Map();
const { ready } = require("./handlers/ready.js")
client.commands = new discord.Collection();
client.aliases = new discord.Collection();
["command"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
client.on("message", async message => {
const prefixMention = new RegExp(`^<@!?${client.user.id}>( |)$`);
if (message.content.match(prefixMention)) {
return message.channel.send(`My prefix is \`${default_prefix}\``);
}
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(default_prefix)) return;
if (!message.member)
message.member = await message.guild.fetchMember(message);
const args = message.content
.slice(default_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);
});
client.on("guildMemberAdd", async member => {
let chx = db.get(`welchannel_${member.guild.id}`);
if (chx === null) {
return;
}
let data = await canva.welcome(member, { link: "https://imgur.com/1BLNtwf" })
const attachment = new discord.MessageAttachment(
data,
"welcome-image.png"
);
client.channels.cache.get(chx).send("Welcome to our Server " + member.user.username, attachment);
});
//LEVEL
const { addexp } = require("./handlers/xp.js")
//LEVEL
client.on("message", async message => {
if(message.author.bot) return;
if(!message.guild) return;
return addexp(message)
})
client.snipes = new Map()
client.on('messageDelete', function(message, channel){
client.snipes.set(message.channel.id, {
content:message.content,
author:message.author.tag,
image:message.attachments.first() ? message.attachments.first().proxyURL : null
})
})
const { GiveawaysManager } = require("discord-giveaways");
// Starts updating currents giveaways
const manager = new GiveawaysManager(client, {
storage: "./handlers/giveaways.json",
updateCountdownEvery: 10000,
default: {
botsCanWin: false,
exemptPermissions: [ "MANAGE_MESSAGES", "ADMINISTRATOR" ],
embedColor: "#FF0000",
reaction: "🎉"
}
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("message", async message => {
if(!message.guild) return;
let prefix = db.get(`default_prefix${message.guild.id}`)
if(prefix === null) prefix =default_prefix;
if(!message.content.startsWith(default_prefix)) return;
})
client.on("guildCreate", guild => {
const { MessageEmbed } = require("discord.js");
const ID = "821627997520920616";
const channel = client.channels.cache.get(ID);
const sowner = guild.owner.user;
if (!channel) return;
const embed = new MessageEmbed()
.setTitle("**I Joined a Server!**")
.addField(`**SERVER NAME**`, `\`\`\`${guild.name}\`\`\``)
.addField(`**SERVER ID**`, `\`\`\`${guild.id}\`\`\``)
.addField(`**SERVER OWNER**`, `\`\`\`${sowner.tag}\`\`\``)
.addField(`**OWNER ID**`, `\`\`\`${sowner.id}\`\`\``)
.addField(`**CREATED ON**`, `\`\`\`${guild.createdAt}\`\`\``)
.addField(`**MEMBERS**`, `\`\`\`${guild.memberCount}\`\`\``)
.setTimestamp()
.setColor("32CD32")
.setFooter(`Servers Count - ${client.guilds.cache.size}`);
channel.send(embed);
});
// Set the bot's online/idle/dnd/invisible status
client.on("ready", () => {
client.user.setStatus("online");
console.log("aquire is ready to use")
});
client.on("message", async message => {
if(!message.guild) return;
let prefix = db.get(`prefix_${message.guild.id}`)
if(prefix === null) prefix = default_prefix;
if(!message.content.startsWith(prefix)) return;
})
client.on("ready", () => {
client.user.setActivity(`@Cs Devs |-help |Servers Count - ${client.guilds.cache.size}`, { type: "LISTENING"})
})
client.login(process.env.TOKEN);