forked from lui2k/csgo-discord-veto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
90 lines (87 loc) · 4.78 KB
/
bot.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
const Discord = require('discord.js');
const client = new Discord.Client();
var activeMaps = ['vertigo', 'dust2', 'inferno', 'mirage', 'nuke', 'overpass', 'ancient'];
var allMaps = ['cache', 'cobble', 'inferno', 'mirage', 'nuke', 'overpass', 'train', 'vertigo', 'dust2', 'canals', 'zoo', 'biome', 'abbey', 'ancient'];
var jbmevidroTournamentMaps = ['2towers', 'caribbean_dolnma', 'crashz_dust_v2', 'desert2', 'dust2', 'grass2','nuke2020', 'poolparty', 'ramps_lego', 'redline', 'ancient'];
var pickSide = ['heads', 'tails'];
var mapPool = [];
var allowBan = false;
var bestOfSelected = false;
var bestOf;
client.on('message', message => {
if (message.content.toLowerCase() === '!mapveto' || message.content.toLowerCase() === '!map veto' || message.content.toLowerCase() === '!veto') {
message.reply('Enter !veto bo1 OR !veto bo3 OR !veto popflash pug');
bestOfSelected = false;
allowBan = false;
}
else if (message.content.toLowerCase() === '!veto popflash pug' && !allowBan && !bestOfSelected) {
bestOf = 1;
bestOfSelected = true;
mapPool = allMaps.slice(0);
message.reply('PUG Map Veto starting: Type !veto MapName to ban any of the following maps: ' + mapPool);
allowBan = true;
}
else if (message.content.toLowerCase() === '!veto flipcoin' || message.content.toLowerCase() === '!veto flipacoin') {
message.reply('the coin has landed on ' + pickSide[Math.floor(Math.random() * pickSide.length)] + '.');
}
else if (message.content.toLowerCase() === '!veto bo1' && !allowBan && !bestOfSelected) {
bestOf = 1;
bestOfSelected = true;
allowBan = false;
message.reply('Enter !Veto ActiveDuty OR !Veto Popflash OR !veto JB.MEVID.RO for a best of ' + bestOf + "match.");
}
else if (message.content.toLowerCase() === '!veto bo3' && !allowBan && !bestOfSelected) {
bestOf = 3;
bestOfSelected = true;
allowBan = false;
message.reply('Enter !Veto ActiveDuty OR !Veto Popflash for a best of ' + bestOf + "match.");
}
else if (message.content.toLowerCase() === '!veto activeduty' && !allowBan && bestOfSelected) {
mapPool = activeMaps.slice(0);
message.reply('Active Duty Map Veto starting: Type !veto MapName to ban any of the following maps: ' + mapPool);
allowBan = true;
}
else if (message.content.toLowerCase() === '!veto popflash' && !allowBan && bestOfSelected) {
mapPool = allMaps.slice(0);
message.reply('Popflash Map Veto starting: Type !veto MapName to ban any of the following maps: ' + mapPool);
allowBan = true;
}
else if (message.content.toLowerCase() === '!veto jb.mevid.ro' && !allowBan && bestOfSelected) {
mapPool = jbmevidroTournamentMaps.slice(0);
message.reply('Map Veto starting for Tournament 1v1 JB.MEVID.RO: Type !veto MapName to ban any of the following maps: ' + mapPool);
allowBan = true;
}
else if (message.content.toLowerCase().indexOf('!veto maplist') === 0 && !allowBan && bestOfSelected) {
mapPool = message.content.slice(13).split(',').map(function (m) { return m.toLowerCase().trim(); });
message.reply('Map list:' + mapPool);
allowBan = true;
}
else if (message.content.toLowerCase() === '!mapsleft' && allowBan) {
message.reply("Maps left: " + mapPool + " (" + (mapPool.length - 1) + ")");
}
else if (message.content.toLowerCase() === '!veto help') {
message.reply("Need help with the Veto Bot? Visit https://github.com/lui2k/csgo-discord-veto or contact the developer: Lui2k#3225 ");
}
else if (message.content.toLowerCase() === '!randommap' || message.content.toLowerCase() === '!random map') {
message.reply(activeMaps[Math.floor(Math.random() * activeMaps.length)]);
}
else if (message.content.toLowerCase() === '!randompopflashmap' || message.content.toLowerCase() === '!random popflash map') {
message.reply(allMaps[Math.floor(Math.random() * allMaps.length)]);
}
else if (message.content.toLowerCase().indexOf('!veto ') === 0 && allowBan) {
var map = message.content.toLowerCase().slice(5).trim();
if (mapPool.indexOf(map) !== -1) {
mapPool = mapPool.filter(function (m) { return m !== map; });
message.reply(map[0].toUpperCase() + map.slice(1) + ' removed. Maps left: ' + mapPool);
if (mapPool.length == bestOf) {
message.reply("you will play on " + mapPool + " (BO" + bestOf + "). Good luck, have fun!");
allowBan = false;
bestOfSelected = false;
}
}
else {
message.reply("Unrecognized command or map is missing from map pool '" + map + "', available maps for veto are: " + mapPool);
}
}
});
client.login(process.env.BOT_TOKEN);