-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
238 lines (211 loc) · 12.2 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");
var prefix = config.prefix;
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
client.user.setActivity(`Serving ${client.guilds.size} servers`);
});
client.on("guildCreate", guild => {
// This event triggers when the bot joins a guild.
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
client.user.setActivity(`Serving ${client.guilds.size} servers`);
});
function case_insensitive_search(str, search_str) {
var result = str.search(new RegExp(search_str, "i"));
if (result > 0)
return true;
else
return false;
}
client.on("guildDelete", guild => {
// this event triggers when the bot is removed from a guild.
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
client.user.setActivity(`Serving ${client.guilds.size} servers`);
});
client.on("message", async message => {
// This event will run on every single message received, from any channel or DM.
// It's good practice to ignore other bots. This also makes your bot ignore itself
// and not get into a spam loop (we call that "botception").
if (message.author.bot) return;
// Also good practice to ignore any message that does not start with our prefix,
// which is set in the configuration file.
// if (message.content.indexOf(config.prefix) !== 0) return;
// Here we separate our "command" name, and our "arguments" for the command.
// e.g. if we have the message "+say Is this the real life?" , we'll get the following:
// command = say
// args = ["Is", "this", "the", "real", "life?"]
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
var channellog = message.member.guild.channels.find('name', 'server-log')
const command = args.shift().toLowerCase();
if (case_insensitive_search(message.content, '18+') ||
case_insensitive_search(message.content, 'my 18+ photos') ||
case_insensitive_search(message.content, 'mes photos nues') ||
case_insensitive_search(message.content, 'nakedphotos') ||
case_insensitive_search(message.content, 'vip') ||
case_insensitive_search(message.content, 'My naked photos') ||
case_insensitive_search(message.content, 'https://viewc.site') ||
case_insensitive_search(message.content, 'https://nakedphotos.club') ||
case_insensitive_search(message.content, 'https://privatepage.vip') ||
case_insensitive_search(message.content, 'my stream 18+') ||
case_insensitive_search(message.content, 'My stream without panties') ||
case_insensitive_search(message.content, '(dating 18+)') ||
case_insensitive_search(message.content, '81zh2y')) {
if (message.member.roles.some(r => ["Administrator", "Moderators", "Core Team", "Helpers", "Enthusiast"].includes(r.name)))
console.log("Cant ban,whitelisted role, message = " + message.content)
else {
if (message.deleted) {
//is deleted already by our other bot,no need to do anything in this case
} else {
await message.delete();
}
// inside a command, event listener, etc.
const exampleEmbed = new Discord.RichEmbed()
.setColor('#0099ff')
.setTitle('Found Blacklisted word')
.setAuthor('NoSpam', 'https://s2.coinmarketcap.com/static/img/coins/200x200/3672.png', 'https://dogec.io')
.setDescription(message.content)
.setThumbnail('https://s2.coinmarketcap.com/static/img/coins/200x200/3672.png')
.setImage(message.author.displayAvatarURL)
.setTimestamp();
channellog.send(exampleEmbed)
await message.guild.ban(message.author.id);
}
}
// Let's go with a few common example commands! Feel free to delete or change those.
if (command === "ping") {
// Calculates ping between sending a message and editing it, giving a nice round-trip latency.
// The second ping is an average latency between the bot and the websocket server (one-way, not round-trip)
const m = await message.channel.send("Ping?");
m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
}
if (command === "testlog") {
var channellog = message.member.guild.channels.find('name', 'server-log');
// inside a command, event listener, etc.
const exampleEmbed = new Discord.RichEmbed()
.setColor('#0099ff')
.setTitle('Found Blacklisted word')
.setAuthor('NoSpam', 'https://s2.coinmarketcap.com/static/img/coins/200x200/3672.png', 'https://dogec.io')
.setDescription("test messagecontent")
.setThumbnail('https://s2.coinmarketcap.com/static/img/coins/200x200/3672.png')
.setImage(message.author.displayAvatarURL)
.setTimestamp();
channellog.send(exampleEmbed)
}
if (command === "say") {
// makes the bot say something and delete the message. As an example, it's open to anyone to use.
// To get the "message" itself we join the `args` back into a string with spaces:
const sayMessage = args.join(" ");
// Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
message.delete().catch(O_o => {});
// And we get the bot to say the thing:
message.channel.send(sayMessage);
}
if (command === "canban") {
// makes the bot say something and delete the message. As an example, it's open to anyone to use.
// To get the "message" itself we join the `args` back into a string with spaces:
// Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
message.delete().catch(O_o => {});
let member = message.mentions.members.first() || message.guild.members.get(args[0]);
if (message.member.roles.some(r => ["Administrator", "Moderators", "Core Team"].includes(r.name)) && member.kickable)
return message.reply("You have perms to ban the user");
else if (!member.kickable) {
return message.reply("You dont have perms to ban the user " + client.users.get(member).username.toString());
} else {
return message.reply("Out of options here")
}
}
if (command === "kick") {
// This command must be limited to mods and admins. In this example we just hardcode the role names.
// Please read on Array.some() to understand this bit:
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
if (!message.member.roles.some(r => ["Administrator", "Moderator"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
// Let's first check if we have a member and if we can kick them!
// message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
// We can also support getting the member by ID, which would be args[0]
let member = message.mentions.members.first() || message.guild.members.get(args[0]);
if (!member)
return message.reply("Please mention a valid member of this server");
if (!member.kickable)
return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
// slice(1) removes the first part, which here should be the user mention or ID
// join(' ') takes all the various parts to make it a single string.
let reason = args.slice(1).join(' ');
if (!reason) reason = "No reason provided";
// Now, time for a swift kick in the nuts!
await member.kick(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
}
if (command === "ban") {
// Most of this command is identical to kick, except that here we'll only let admins do it.
// In the real world mods could ban too, but this is just an example, right? ;)
if (!message.member.roles.some(r => ["Administrator"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member)
return message.reply("Please mention a valid member of this server");
if (!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if (!reason) reason = "No reason provided";
await member.ban(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
}
if (command === "purge") {
// This command removes all messages from all users in the channel, up to 100.
// get the delete count, as an actual number.
const deleteCount = parseInt(args[0], 10);
// Ooooh nice, combined conditions. <3
if (!deleteCount || deleteCount < 2 || deleteCount > 100)
return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
// So we get our messages, and delete them. Simple enough, right?
const fetched = await message.channel.fetchMessages({ limit: deleteCount });
message.channel.bulkDelete(fetched)
.catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
}
});
// client.on('message', async message => {
// console.log(message)
// // if (message.author !== client.user) return;
// if (message.content.startsWith(prefix + 'ping')) {
// message.delete()
// message.channel.send(`**Pong!** | ${client.ping}ms`)
// }
// if (message.content.startsWith(prefix + 'userinfo')) {
// message.delete()
// let member5 = message.mentions.members.first();
// const embed = new Discord.RichEmbed()
// if (!member5) {
// message.channel.send(`:warning: Please mention a user!`)
// } else {
// if (!member5.presence.game) {
// embed.setDescription(`***USER*** *INFOMATION*\n \nUSERNAME: **${member5.user.tag}**\nID: **${member5.id}**\nCREATED: **${member5.createdAt}**\nPLAYING: **NOTHING**`)
// embed.setAuthor(member5.user.tag, member5.user.avatarURL)
// embed.setFooter(`userinfo command | run by ${message.author.tag}`)
// embed.setThumbnail(member5.user.avatarURL)
// embed.setColor(member5.highestRole.color)
// message.channel.send({ embed });
// } else {
// embed.setDescription(`***USER*** *INFOMATION*\n \nUSERNAME: **${member5.user.tag}**\nID: **${member5.id}**\nCREATED: **${member5.createdAt}**\nPLAYING: **${member5.presence.game.name}**`)
// embed.setAuthor(member5.user.tag, member5.user.avatarURL)
// embed.setFooter(`userinfo command | run by ${message.author.tag}`)
// embed.setThumbnail(member5.user.avatarURL)
// embed.setColor(member5.highestRole.color)
// message.channel.send({ embed });
// }
// }
// }
// if (case_insensitive_search(message.content,'18+') == 0 ||
// case_insensitive_search(message.content,'my 18+ photos') == 0 ||
// case_insensitive_search(message.content,'mes photos nues') == 0 ||
// case_insensitive_search(message.content,'nakedphotos') == 0 ||
// case_insensitive_search(message.content,'vip') == 0 ||
// case_insensitive_search(message.content,'81zh2y') == 0) {
// await message.guild.ban(message.author.id)
// message.channel.send('Banned Spammer,Begone Spammer');
// }
// });
client.login(config.token);