-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
281 lines (232 loc) · 9.17 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
const Discord = require("discord.js");
const Enmap = require("enmap");
//DISCORD.JS 12
const client = new Discord.Client();
client.lootban = new Enmap({name: "lootban"});
//Date.prototype.toUnixTime = function() { return this.getTime()/1000|0 };
//Date.time = function() { return new Date().toUnixTime(); }
const config = require("./config.json");
client.on("ready", () => {
console.log(`Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
//playing:
client.user.setActivity(`Lootban Simulator`);
});
client.on("message", async message => {
//ignore other bots
if(message.author.bot) return;
//ignore any message that does not start with our prefix
if(!message.content.startsWith(config.prefix)) return;
//separate our "command" name, and our "arguments" for the command.
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
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.ws.ping)}ms`);
}
if(command === "lootban") {
if(!message.member.roles.cache.some(r=>["Officers"].includes(r.name)))
return message.reply("¿A quién vas a lootbanear tu, joputa?");
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord. Menciona bien.`);
let reason = args.slice(1).join(' ');
if(!reason) return message.reply(`¿Y por qué razón debería yo lootbanear a ${member}?`);
message.delete().catch(O_o=>{});
const key = `${message.guild.id}-${member.id}`;
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: Date.now(),
why: reason
});
client.lootban.inc(key, "lootbans");
client.lootban.set(key, Date.now(), "timestamp");
client.lootban.set(key, reason, "why");
const embed = new Discord.MessageEmbed()
.setTitle("PUM! LOOTBANEAO!")
.setColor(0xF58A42)
.addFields(
{name:`Infractor: `, value: `${member.displayName}`},
{name:`Razón: `, value: `${reason}`},
)
return message.channel.send({embed});
}
// if(command === "test1"){
// message.channel.send(`${message.mentions.members.first()}`);
// }
// if(command === "test2"){
// message.channel.send(`${message.author}`);
// }
if(command === "standing") {
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord. Menciona bien.`);
const key = `${message.guild.id}-${member.id}`;
// if(client.lootban.get(key, "timestamp") != 0 && (Date.now() - client.lootban.get(key, "timestamp")) > 864000000){
// client.lootban.set(key, "timestamp", 0);
// }
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: 0,
why: "-"
});
message.channel.send(`${member} ha sido lootbaneado **${client.lootban.get(key, "lootbans")}** veces.`);
}
if(command === "estabanned") {
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord. Menciona bien.`);
const key = `${message.guild.id}-${member.id}`;
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: 0,
why: "-"
});
if((Date.now() - client.lootban.get(key, "timestamp")) > 864000000){
message.channel.send(` tranquilo acho, que ${member} **no** está lootbanned.`);
}else{
var f = new Date(client.lootban.get(key, "timestamp"));
var fs = new Date(client.lootban.get(key, "timestamp")+864000000);
message.reply('hmm...');
const embed = new Discord.MessageEmbed()
.setTitle("Lootbanned")
.setColor(0xCA0000)
.addFields(
{name:`Infractor: `, value: `${member.displayName}`},
{name:`Desde: `, value: `${f.toLocaleString()}`},
{name:`Por: `, value: `${client.lootban.get(key, "why")}`},
{name:`Hasta: `, value: `${fs.toLocaleString()}`},
)
return message.channel.send({embed});
}
}
if(command === "indulto") {
if(!message.author.id === message.guild.owner) return message.reply("¿Eres Kairoz? No me lo parece.");
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord.`);
const key = `${message.guild.id}-${member.id}`;
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: 0,
why: "-"
});
if(!client.lootban.get(key, "lootbans") == 0){
client.lootban.dec(key, "lootbans");
}
client.lootban.set(key, 0, "timestamp");
client.lootban.set(key, "-", "why");
message.channel.send(`${member} indultao... pussies.`);
}
if(command === "unlootban") {
if(!message.member.roles.cache.some(r=>["Admins"].includes(r.name)))
return message.reply("No can do.");
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord.`);
const key = `${message.guild.id}-${member.id}`;
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: 0,
why: "-"
});
client.lootban.set(key, 0, "timestamp");
client.lootban.set(key, "-", "why");
message.channel.send(`${member} indultao... pussies.`);
}
if(command === "modts"){
if(!message.author.id === message.guild.owner) return message.reply("¿Eres Kairoz? No me lo parece.");
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord. Menciona bien.`);
let delta = args.slice(1).join(' ');
if(!delta) return message.reply(`Missing delta t`);
const key = `${message.guild.id}-${member.id}`;
client.lootban.ensure(key,{
user: member,
lootbans: 0,
timestamp: 0,
why: "-"
});
var x = client.lootban.get(key, "timestamp") - Number(delta);
client.lootban.set(key, x, "timestamp");
return message.channel.send(`Edited TS`);
}
if(command === "hard.reset") {
if(!message.author.id === message.guild.owner) return message.reply("¿Eres Kairoz? No me lo parece.");
// if(!message.member.roles.cache.some(r=>["Admins"].includes(r.name)))
// return message.reply("No can do.");
let member = message.mentions.members.first();
if(!member)
return message.reply(`Acho, ${member} no está en este Discord.`);
const key = `${message.guild.id}-${member.id}`;
client.lootban.set(key, 0, "timestamp");
client.lootban.set(key, "-", "why");
client.lootban.set(key, 0, "lootbans");
message.channel.send(`${member} full reset.`);
}
if(command === "lootprio"){
message.channel.send("Toma loot prio:", {files: ["https://i.imgur.com/PZTSJOP.png"]});
}
if(command === "help"){
//message.delete().catch(O_o=>{});
const embed = new Discord.MessageEmbed()
.setTitle("Comandos disponibles")
.setColor(0x00AE86)
.addFields(
{name:`+standing @alguien`, value: `Consulta la posicion en el ranking.`},
{name:`+estabanned @alguien`, value: `Consulta el estado del ban, fechas y motivo.`},
{name:`+lootbanned`, value: `Muestra los lootbans actuales.`},
{name:`+ranking`, value: `Muestra el top 5 más baneado (histórico).`},
{name:`+lootprio`, value: `¿Cuándo me toca lootear?`},
{name:`+ping`, value: `Ping al server.`},
)
return message.channel.send({embed});
}
if(command === "ranking"){
//message.delete().catch(O_o=>{});
const arr = client.lootban.array();
const sorted = arr.sort((a,b) => b.lootbans - a.lootbans);
const top10 = sorted.splice(0,5);
const embed = new Discord.MessageEmbed()
.setTitle("Lootban Ranking")
.setDescription("Top 5 más baneados")
.setColor(0x00AE86);
for(const data of top10) {
if(!data.lootbans==0){
embed.addField(`${data.user.displayName}`, `${data.lootbans} veces.`);
}
}
return message.channel.send({embed});
}
if(command === "lootbanned"){
const arr = client.lootban.array();
var lb = new Array();
for(const data of arr) {
if(!((Date.now() - data.timestamp) > 864000000)){
lb.push(data);
}
}
const sorted = lb.sort((a,b) => a.timestamp - b.timestamp);
// arr.array.forEach(element => {
// if(!((Date.now() - arr.timestamp) > 864000000)){
// lb.push(element);
// }
// });
const embed = new Discord.MessageEmbed()
.setTitle("Lootbans actuales")
.setColor(0xF5E342);
for(const data of sorted) {
var fs = new Date(data.timestamp+864000000);
embed.addField(`${data.user.displayName}`, `Hasta: ${fs.toDateString()}`, true);
}
return message.channel.send({embed});
}
});
client.login(config.token);