-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
410 lines (355 loc) · 13.3 KB
/
main.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
const dotenv = require('dotenv');
if (process.env.NODE_ENV !== 'production')
dotenv.config();
const Discord = require("discord.js");
const schedule = require('node-schedule');
const config = require("./config.json");
const client = new Discord.Client();
const { BOT_TOKEN } = process.env;
client.on('ready', () => { console.log("Bot iniciado com sucesso") });
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith("!")) return;
console.log(message.content)
try {
switch (message.content.slice(1).split(' ')[0].toLowerCase()) {
case "ping":
const timeTaken = Date.now() - message.createdTimestamp;
message.reply(`Pong! Essa mensagem teve uma latência de ${timeTaken}ms.`);
break;
case "rafa":
rafaCommand(message);
break;
case "rafa2":
rafa2Command(message);
break;
case "rafa3":
rafa3Command(message);
break;
case "rafadeploy":
rafaDeployCommand(message);
break;
case "rafaqa":
rafaQACommand(message);
break;
case "cronometro":
cronometroCommand(message);
break;
case "crossfit":
case "almoçareirnocross":
case "cross":
crossCommand(message);
break;
case "vpn":
vpnCommand(message);
break;
case "finalizar":
finalizarCommand(message);
break;
case "vitao":
vitaoCommand(message);
break;
case "vita1":
vita1Command(message);
break;
case "almoço":
case "almoco":
almocoCommand(message);
break;
case 'cafezin':
case "lanchinho":
case "lanche":
cafezinCommand(message);
break;
case "afk":
case "agua":
case "banheiro":
afkCommand(message);
break;
case "send":
sendCommand(message);
break;
case 'daily':
dailyCommand(message);
break;
case 'updatephp':
updatephpCommand(message);
break;
case 'help':
helpCommand(message);
break;
case 'reuniao':
case 'reunião':
reuniaoCommand(message);
break;
case 'devolta':
case 'voltei':
case 'back':
devoltaCommand(message);
break;
case 'academia':
case 'treinardeverdade':
academiaCommand(message);
break;
case 'deploynasexta':
deployNaSextaCommand(message);
break;
case 'tipoitem':
tipoItemCommand(message);
break;
case 'saladocris':
sala_do_crisCommand(message);
break;
case 'macarrao':
case 'macarrão':
macarraoCommand(message);
break;
case 'php':
phpCommand(message);
break;
case 'sextouend':
sextouendCommand(message);
break;
case 'baddeploy':
baddeployCommand(message);
break;
case 'gooddeploy':
gooddeployCommand(message);
break;
case 'hollywood':
hollywoodCommand(message);
break;
default:
console.log(message.content.slice(1).toLowerCase())
message.channel.send('Comando inválido.');
break;
}
} catch (e) {
console.log(`Error command: ${message.content}`)
console.log(e);
console.log(JSON.stringify(e));
}
})
client.login(BOT_TOKEN);
function getAfkVoiceChannelId(message) {
const discordId = message.url.split('channels')[1].split('/')[1];
//@ts-ignore
const chat = client.channels.cache.find(c => c.type == 'voice' && c.name.toLowerCase() == 'afk' && c.guild == discordId)
//@ts-ignore
return chat.id
}
function getReuniaoVoiceChannelId(message) {
const discordId = message.url.split('channels')[1].split('/')[1];
//@ts-ignore
const chat = client.channels.cache.find(c => c.type == 'voice' && (c.name.toLowerCase() == 'reuniao' || c.name.toLowerCase() == 'reunião') && c.guild == discordId)
//@ts-ignore
return chat.id
}
function getNotificacoesVoiceChannelId(message) {
const discordId = message.url.split('channels')[1].split('/')[1];
//@ts-ignore
const chat = client.channels.cache.find(c => c.type == 'text' && c.name.toLowerCase() == 'notificações' && c.guild == discordId)
//@ts-ignore
return chat.id
}
function getGeneralChannelId(message) {
const discordId = message.url.split('channels')[1].split('/')[1];
//@ts-ignore
const chat = client.channels.cache.find(c => c.type == 'text' && c.name.toLowerCase() == 'general' && c.guild == discordId)
//@ts-ignore
return chat.id
}
function getAlmocoVoiceChannelId(message) {
const discordId = message.url.split('channels')[1].split('/')[1];
//@ts-ignore
const chat = client.channels.cache.find(c => c.type == 'voice' && c.name.toLowerCase() == 'almoço' && c.guild == discordId)
//@ts-ignore
return chat.id
}
function deployNaSextaCommand(message) {
message.channel.send("Pega a Becks pq sextou com deploy!", { files: ['./img/sextou_com_deploy.jpg'] });
}
function academiaCommand(message) {
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} foi pra academia!`);
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function devoltaCommand(message) {
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} está de volta!`);
}
function reuniaoCommand(message) {
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} está em reunião!`);
message.member.voice.setChannel(getReuniaoVoiceChannelId(message));
}
function rafaCommand(message) {
message.channel.send("Precisamos de férias!", { files: ['./img/frajuto.png'] });
}
function sextouendCommand(message) {
message.channel.send("Weekend dev", { files: ['./img/sextouend.png'] });
}
function macarraoCommand(message) {
message.channel.send("Macarroneee ╰(*°▽°*)╯", { files: ['./img/boaSorteMacarrao.jpg'] });
}
function rafa2Command(message) {
message.channel.send("Rafa-Multi-Threads v3.cR0$$!", { files: ['./img/rafa-multi-threads.png'] });
}
function rafa3Command(message) {
message.channel.send("Botando o bug na rede!", { files: ['./img/saiDaquiBug.gif'] });
}
function rafaDeployCommand(message) {
message.channel.send("Quando o bruno pede pra fazer deploy na noite!", { files: ['./img/rafaDeployNaSextaANoite.jpeg'] });
}
function rafaQACommand(message) {
message.channel.send("Aprovado pelo rafa! :rafa_QA:", { files: ['./img/selo_rafa_de_qualidade.png'] });
}
function crossCommand(message) {
//@ts-ignore
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} foi crossfitar!`);
//@ts-ignore
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function vpnCommand(message) {
//@ts-ignore
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} está usando a VPN!`);
//@ts-ignore
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function finalizarCommand(message) {
//@ts-ignore
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} está finalizando por hoje, até mais!`);
//@ts-ignore
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function vitaoCommand(message) {
message.channel.send("Rafa tá de ferias!?", { files: ['./img/rafa_ta_de_ferias.png'] });
}
function hollywoodCommand(message) {
message.channel.send("Bora pra hollywood =) ", { files: ['./img/hollywood.jpeg'] });
}
function tipoItemCommand(message) {
message.channel.send("Everyday I wake up TipoItem", { files: ['./img/everyday_tipo_item.png'] });
}
function baddeployCommand(message) {
message.channel.send("Quando o deploy da ruim", { files: ['./img/deploy_deu_ruim.png'] });
}
function updatephpCommand(message) {
message.channel.send("Update sem where de belo monte.", { files: ['./img/updatephp.jpg'] });
}
function gooddeployCommand(message) {
message.channel.send("Quando o deploy da bom", { files: ['./img/deploy_deu_bom.png'] });
}
function sala_do_crisCommand(message) {
message.channel.send(`Olá ψ(._. )>`, { files: ['./img/sala_do_cris.png'] });
}
function phpCommand(message) {
message.channel.send(`PH~~ili~~P~~i~~`, { files: ['./img/php.png'] });
}
function vita1Command(message) {
message.channel.send("Vita1: futuro arquiteto de software", { files: ['./img/vita1.png'] });
}
function cronometroCommand(message) {
const qtdRounds = Number(message.content.split(" ")[1]);
if (qtdRounds && Number.isInteger(qtdRounds)) {
message.channel.send(`Cronometro iniciado! \nRound 1 de ${qtdRounds}! \nTempo: 60s`).then((msgRef) => {
startCronometro(msgRef, qtdRounds, 1, 60);
});
}
}
function startCronometro(msgRef, roundTotal, roundAtual, tempo) {
if (roundAtual <= roundTotal) {
//msgRef.edit(`Cronometro iniciado! \n Round ${roundAtual} de ${roundTotal}! \n Tempo: ${tempo}s`)
cronometrar(msgRef, roundTotal, roundAtual, tempo);
} else {
msgRef.edit(`Cronometro finalizado! \nRound ${roundAtual - 1} de ${roundTotal}! \nTempo: Over!`)
}
}
function cronometrar(msgRef, roundTotal, roundAtual, tempo) {
if (tempo > 0) {
msgRef.edit(`Cronometro iniciado! \nRound ${roundAtual} de ${roundTotal}! \nTempo: ${tempo}s`)
setTimeout(() => {
cronometrar(msgRef, roundTotal, roundAtual, tempo - 5);
}, 5000);
} else {
startCronometro(msgRef, roundTotal, roundAtual + 1, 60);
}
}
function almocoCommand(message) {
//@ts-ignore
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} foi almoçar!`);
//@ts-ignore
message.member.voice.setChannel(getAlmocoVoiceChannelId(message));
}
function cafezinCommand(message) {
//@ts-ignore
client.channels.cache.get(getNotificacoesVoiceChannelId(message)).send(`${message.member.displayName} foi tomar um cafezin e ja volta!`);
//@ts-ignore
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function afkCommand(message) {
const notificaoId = getNotificacoesVoiceChannelId(message)
//@ts-ignore
client.channels.cache.get(notificaoId).send(`${message.member.displayName} precisou sair e ja volta!`);
//@ts-ignore
message.member.voice.setChannel(getAfkVoiceChannelId(message));
}
function sendCommand(message) {
message.channel.send(message.content.slice(6));
}
function dailyCommand(message) {
try {
message.channel.send("@everyone Daily!");
} catch (e) {
console.log(e);
}
}
const helpCommandInfo = {
help: 'Exibe uma lista dos comandos',
cronometro: 'Inicia um cronometro de 60s -> !cronometro 5',
ping: 'Tempo de resposta do bot',
rafa: 'Envia uma mensagem precisando de férias',
rafa2: 'Não sei tem quer ver schrödinger',
rafa3: 'Rafa jogador botando os bugs na rede',
rafadeploy: 'Quando pedem pra fazer deploy a noite!! :/ :/',
rafaQA: 'Selo de qualidade do rafa',
vitao: 'Rafa tá de ferias!?',
vita1: 'Vita1: futuro arquiteto de software',
updatephp: 'Update selo de qualidade do php',
almoco: 'Almoçar',
cafezin: 'Toma um cafézin',
afk: 'Fica AFK',
cross: 'Crossfitar',
vpn: 'Usa a VPN',
finalizar: 'Até mais!',
send: 'Envia uma mensagem',
daily: 'Daily!',
academia: 'Bora treinar',
reuniao: 'Estou em reunião',
devolta: 'Voltei!',
deployNaSexta: 'Pega a Becks pq sextou com deploy!',
tipoItem: 'Everyday I wake up TipoItem',
saladocris: 'Sala do Cris',
php: 'PH~~ili~~P~~i~~',
macarrao: 'Boa tarde, Macarrone!',
sextouend: 'Backend? No. Frontend? No. Weekend ╰(*°▽°*)╯ !',
baddeploy: 'Quando o deploy da ruim',
gooddeploy: 'Quando o deploy da bom',
hollywood: 'Bora pra hollywwood!',
}
function helpCommand(message) {;
message.channel.send({
embed: {
color: 3447003,
title: "Comandos:",
fields: [{
name: "Valor",
value: Object.keys(helpCommandInfo).map(i => `!${i}`).join('\n'),
inline: true
},
{
name: "Descrição",
value: Object.values(helpCommandInfo).map(i => `${i}`).join('\n'),
inline: true
}
]
}
});
}