-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
157 lines (116 loc) · 4.66 KB
/
server.js
File metadata and controls
157 lines (116 loc) · 4.66 KB
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
const { token, default_prefix } = require("./config.json");
const { badwords } = require("./data.json")
const { config } = require("dotenv");
const discord = require("discord.js"); //Gonna use Discord.js Module xD
const client = new discord.Client({
disableEveryone: true // what does this disable thing do?
});
const db = require("quick.db"); //WE WILL BE USING QUICK.DB
const { addexp } = require("./handlers/xp.js");
client.commands = new discord.Collection();
client.aliases = new discord.Collection();
const { CanvasSenpai } = require("canvas-senpai")
const canva = new CanvasSenpai();
["command"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
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
})
})
client.on("ready", () => { //When bot is ready
console.log("Flash Has Been started running and speed increased!")
client.user.setActivity(db.get(`status`)) //It will set status :)
})
//IS URL FUNCTION - START
function is_url(str) {
let regexp = /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
if(regexp.test(str)) {
return true;
} else {
return false;
}
}
//STOP
client.on("message", async message => {
if (message.author.bot) return;
//START
if(!message.member.hasPermission("ADMINISTRATOR")) {
if(is_url(message.content)) {
const ignored_channels = ['749631724165529720', '749631725696450641']
if (!ignored_channels.includes(message.channel.id)) {
return message.delete()
}
}
let confirm = false;
//NOW WE WILL USE FOR LOOP
var i;
for(i = 0;i < badwords.length; i++) {
if(message.content.toLowerCase().includes(badwords[i].toLowerCase())) {
// uncomment this line if you want to see why a certain message is being flagged as a badword
console.log(message.content.toLowerCase(), 'matches', badwords[i].toLowerCase())
confirm = true;
}
}
if(confirm) {
message.delete()
return message.channel
return message.channel.send("You are not allowed to send badwords here")
}
}
//END
if (!message.guild) return;
let prefix = db.get(`prefix_${message.guild.id}`);
if (prefix === null) prefix = default_prefix;
if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
const embed = new discord.MessageEmbed()
.setDescription('my prefix is f! or whatever i am guessing thats why you tagged me')
.setColor('#ff00f3')
return message.channel.send(embed)
}
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
let blacklist = await db.fetch(`blacklist_${message.author.id}`)
if (blacklist === "Blacklisted") return message.reply("You are blacklisted from the bot!")
if (!message.member)
message.member = await 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 cmdx = db.get(`cmd_${message.guild.id}`)
if(cmdx) {
let cmdy = cmdx.find(x => x.name === cmd)
if(cmdy) message.channel.send(cmdy.responce)
}
// Get the command
let command = client.commands.get(cmd);
// If none is found, try to find it by alias
if (!command) command = client.commands.get(client.aliases.get(cmd));
// If a command is finally found, run the command
if (command) command.run(client, message, args);
return addexp(message);
//All codes link in description
}); //All codes link in description
//GONNA USE EVENT HERE
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://i.pinimg.com/originals/f3/1c/39/f31c39d56512dc8fbf30f9d0fb3ee9d3.jpg" })
const attachment = new discord.MessageAttachment(
data,
"welcome-image.png"
);
client.channels.cache.get(chx).send("Welcome to our Server " + member.user.username, attachment);
});
//Login
client.login(process.env.token);