-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
253 lines (244 loc) · 10.6 KB
/
server.js
File metadata and controls
253 lines (244 loc) · 10.6 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
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
/* jshint esversion: 6 */
const myConfig = require('./config.json');
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const bodyParser = require('body-parser');
const Discord = require('discord.js');
const bot = new Discord.Client({autoReconnect:true});
const urlRegex = /[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ig
app.set('serverPort', myConfig.serverPort);
app.use(bodyParser.urlencoded({
extended: true
}));
let botInvites = [];
app.use(bodyParser.json());
const prefix = '!'
bot.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(' ');
const command = args.shift().toLowerCase();
if (command === 'kern') {
message.channel.sendMessage('https://clips.twitch.tv/MistyNiceBibimbapTheRinger');
} else if (command === 'kern2') {
message.channel.sendMessage('https://clips.twitch.tv/SarcasticConcernedHedgehogTebowing');
} else if (command === 'varcster') {
message.channel.sendMessage('https://www.twitch.tv/videos/68214198');
} else if (command === 'zesty') {
message.channel.sendMessage('https://clips.twitch.tv/SpoopyFreezingWrenOSsloth');
} else if (command === 'sephyr') {
message.channel.sendMessage('https://www.youtube.com/watch?v=p9UZnxDVxTY');
} else if (command === 'dimi') {
message.channel.sendMessage('https://clips.twitch.tv/PowerfulFancyOcelotAliens');
} else if (command === 'fire') {
message.channel.sendMessage('https://youtu.be/V552exgHaWU');
} else if (command === 'stagger') {
message.channel.sendMessage('When they nerf stagger \n https://cdn.discordapp.com/attachments/444357789025042432/507587021213007883/image0.jpg');
} else if (command === 'mrblizzard') {
message.channel.sendMessage('https://youtu.be/dstyQa9JRgY');
} else if (command === 'diminudes') {
message.channel.sendMessage('ಠ_ಠ');
} else if (command === 'seabreeze') {
message.channel.sendMessage(`PriestBot: How good is Seabreeze for shadow? Is the haste proc worth the lack of secondaries?\n\nIts not awful but its not amazing either. Mostly it doesnt change your gear prioritization. Its worth a tiny bit less than staves with BIS stats at the same ilvl`);
} else if (command === 'deism') {
message.channel.sendMessage('https://clips.twitch.tv/BashfulCourageousDootHassaanChop');
} else if (command === 'bthelight') {
message.channel.sendMessage('https://www.twitch.tv/videos/127633788');
} else if (command === 'swampletics') {
message.channel.sendMessage(`Meet Swampletics, my Morytania locked ultimate ironman. After recently maxing my ultimate ironman I decided to up the ante, and forge my own journey from scratch. No banking, no trading, but this time I can't leave Morytania.\n<https://youtu.be/rk5XuqLrf3U>`)
} else if (command === 'crenix') {
message.channel.sendMessage('https://clips.twitch.tv/BashfulMiniatureSparrowFeelsBadMan');
} else if (command === 'clandon') {
message.channel.sendMessage('https://cdn.discordapp.com/attachments/287743008861061121/595790922097229824/unknown.png')
} else if (command === 'bobcommands') {
message.channel.sendMessage(`!kern\n!varcster\n!zesty\n!sephyr\n!dimi\n!fire\n!stagger\n!mrblizzard\n!diminudes\n!seabreeze\n!kern2\n!deism\n!bthelight\n!swampletics\n!crenix\n!clandon\n!bobcommands`);
}
});
bot.on('ready', () => {
console.log('I am ready!');
let guild = bot.guilds.find(val => val.id === myConfig.guildID);
if (guild.available) {
guild.fetchInvites()
.then(invites => {
for (const invite of invites.array()) {
if (invite.inviter && invite.inviter.id &&
invite.inviter.id === myConfig.botID && invite.uses !== null &&
invite.uses === 0)
botInvites.push(invite.code);
}
})
.catch(console.error);
}
});
bot.on('guildMemberAdd', (member) => {
let guild = bot.guilds.find(val => val.id === myConfig.guildID);
if (guild.available) {
guild.fetchInvites()
.then(invites => {
for (const invite of invites.array()) {
for (var i = 0; i < botInvites.length; i++) {
if (invite.code === botInvites[i] && invite.uses >= 1) {
createApplicantUser(member, invite, i);
}
}
}
})
.catch(console.error);
}
});
const createApplicantUser = (member, invite, i) => {
member.addRole(myConfig.applicantRoleID)
.then((member) => {
if (invite.channel) {
invite.channel.overwritePermissions(member, {
SEND_MESSAGES: true,
READ_MESSAGES: true,
EMBED_LINKS: true,
READ_MESSAGE_HISTORY:true,
ATTACH_FILES: true
})
.then(() => {
member.setNickname(invite.channel.name)
.then((applicant) => {
invite.channel.sendMessage(`${applicant.user} Thanks for applying to revive. You can find your application here please feel free to ask any questions.`);
})
.catch(console.error);
})
.catch(console.error);
}
})
.catch(console.error);
invite.delete()
.then(invite => {
botInvites.splice(i,1);
})
.catch(console.error);
};
app.post('/discord/createGuildApp', (req,res) => {
const applicationData = {
name:req.body.name,
loc:req.body.loc,
tag:req.body.tag,
armory:req.body.armory,
sscombat:req.body.sscombat,
headset:req.body.headset,
logs:req.body.logs,
role:req.body.role,
awp:req.body.awp,
prog:req.body.prog,
left:req.body.left,
rotation:req.body.rotation,
resources:req.body.resources,
hear:req.body.hear,
crit:req.body.crit,
sit:req.body.sit,
schedule:req.body.schedule,
beta:req.body.beta,
about:req.body.about,
joke:req.body.joke
};
let applicationText = `**What is your Name, Age and Sex?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.name}\n\n
**Provide the location you will primarily will be playing from and a speedtest.net screenshot from the Chicago server**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.loc}\n\n
**What is your Battle.net Tag**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.tag}\n\n
**Link to your main characters and alternate character's armory **\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.armory}\n\n
**Post a screenshot of your character in combat**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.sscombat}\n\n
**Do you have a functioning headset with microphone that you can use in Discord?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.headset}\n\n
**Post your recent warcraft logs**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.logs}\n\n
**What role and spec are you applying for**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.role}\n\n
**Neck Level **\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.awp}\n\n
**List Previous Mythic/Heroic Progression Experiences**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.prog}\n\n
**Name your last TWO raiding guilds and the reason for leaving them?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.left}\n\n
**Take us through your opening rotation on a SINGLE TARGET fight. (Healers Ignore this)**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.rotation}\n\n
**What resources do you use to improve yourself?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.resources}\n\n
**How did you hear about us?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.hear}\n\n
**How do you handle criticism and adult humor?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.crit}\n\n
**You may be asked to sit on some fights for composition, gear, or general skill level how do you feel about that?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.sit}\n\n
**Do you have any commitments or schedule changes that we should know about?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.schedule}\n\n
**Are you willing to test new content in PTR/Alpha/Beta?**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.beta}\n\n
**Tell us a little bit about yourself. The more we know the better!**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.about}\n\n
**Tell us a joke**\n
━━━━━━━━━━━━━━━━━━━━━━━━\n
${applicationData.joke}\n\n`;
applicationText = applicationText.replace(urlRegex, (match) => {
return `<${match}>`
})
let guild = bot.guilds.find(val => val.id === myConfig.guildID);
let _this = this;
if (guild.available) {
const channel = applicationData.tag.replace('#','-');
const permissions = [
{ id: '231944378577321984', type: 'role', deny: 0, allow: 3072 },
{ id: '291440686916698112', type: 'role', deny: 0, allow: 3072 },
{ id: '231933464201527298', type: 'role', deny: 1024, allow: 0 },
{id: '231944387255336960',type: 'role',deny: 8192,allow: 3072 },
{id: '231944378476658690',type:'role',deny:0,allow:3072},
{id: '231948453737922580',type: 'role',deny: 8192,allow: 3072 }
];
guild.createChannel(channel, 'text', permissions)
.then(channel => {
channel.createInvite({
temporary: false,
maxUses: 2
}).then(invite => {
botInvites.push(invite.code);
res.send(invite.url);
})
.catch(console.error);
channel.sendMessage(`@everyone New application please review.`).then(message => {
channel.sendMessage(applicationText, {split:true})
.then(message => {
})
.catch(console.error);
}).catch(console.error());
})
.catch(console.error);
}
});
app.get('/discord', (req,res) => {
res.send("Revive-Discord-Bot");
});
app.get('/discord/callback', (req,res) => {
//Handle Discord Request URI?
});
bot.login(myConfig.discordKey);
server.listen(app.get('serverPort'));
console.log('Listening on port', app.get('serverPort'));