-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
359 lines (314 loc) · 12.1 KB
/
Copy pathindex.js
File metadata and controls
359 lines (314 loc) · 12.1 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
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
// Constants
const Discord = require("discord.js");
const client = new Discord.Client();
const settings = require("./settings.json");
const request = require('request');
const funcs = require('./functions.js');
const prefix = settings.prefix;
const ytUser = settings.username;
const defaultRole = settings.defaultRole;
const staffRoles = settings.staffRoles;
// Variables
var commandList = [];
var rulesList = funcs.getRulesList();
var textList = [];
var pepper = false;
var doggy = false;
var rock = false;
// All the commands that users can execute.
commandList.push([prefix + "help", "Shows this list."]);
commandList.push([prefix + "rules", "Shows the server rules."])
commandList.push([prefix + "subcount", "Show the subscriber amount from Youtube."]);
commandList.push([prefix + "viewcount", "Shows the amount of views on Youtube."]);
commandList.push([prefix + "membercount", "Show the member amount from Discord."]);
commandList.push([prefix + "texteffects", "Shows the possible text effects."]);
commandList.push([prefix + "memes", "Gives information about posting memes."]);
commandList.push([prefix + "searchVid 'Name of video'", "Search a video or SmashLook."]);
commandList.push([prefix + "links", "Get all links."]);
// Text-Effects
textList.push("*Italic*");
textList.push("**Bold**");
textList.push("__Underlined__");
textList.push("~~Striketrough~~");
// When the bot starts up, log it to the console.
client.on("ready", () => {
console.log("I\'m Online");
client.user.setActivity(prefix + "help");
});
// When a User joins the server for the first time.
client.on('guildMemberAdd', member => {
// Private message with rules to User that joins.
var rulesString = "**Rules:**\n";
var tempString = "";
for (var i = 0; i < rulesList.length; i++) {
tempString = (i+1) + ") " + rulesList[i] + "\n";
rulesString += tempString;
}
tempString = "\n\nYou can always use " + prefix + "help if you need information regarding the commands.";
rulesString += tempString;
member.user.send(rulesString);
// Gives the new user the 'Smashers'-role.
member.addRole(member.guild.roles.find('name', defaultRole));
const channel = member.guild.channels.find('name', 'server_log');
const embedNewUser = new Discord.RichEmbed();
embedNewUser.setColor('80f31f');
embedNewUser.setAuthor(member.user.username + "#" + member.user.discriminator + " (" + member.user.id + ")", member.user.displayAvatarURL);
embedNewUser.setFooter('User joined');
embedNewUser.setTimestamp();
channel.send(embedNewUser);
console.log("New user joined!");
});
//When a person leaves the server.
client.on('guildMemberRemove', member => {
const channel = member.guild.channels.find('name', 'server_log');
const embedLeaveUser = new Discord.RichEmbed();
embedLeaveUser.setColor('ff2605');
embedLeaveUser.setAuthor(member.user.username + "#" + member.user.discriminator + " (" + member.user.id + ")", member.user.displayAvatarURL);
embedLeaveUser.setFooter('User left');
embedLeaveUser.setTimestamp();
channel.send(embedLeaveUser);
console.log("User left!");
});
// Commands.
client.on("message", message => {
if (message.author.id === "254533641382658048" && pepper == true) {
message.react('🌶');
console.log("Pepper");
}
if (message.author.id === "104618219347648512" && doggy == true) {
message.react('🌭');
console.log("Doggy");
}
if (message.author.id === "301711821981614082" && rock == true) {
message.react('🇫');
message.react('🇦');
message.react('🇮');
message.react('🇷');
message.react('🇾');
console.log("Rock");
}
if (message.author.id === "96651399605006336" && message.content === (prefix + "togglePepper")) {
let msg = "Pepper is now: ";
if (pepper == true) {
pepper = false;
msg += "false!";
}
else if (pepper == false) {
pepper = true;
msg += "true!";
}
message.channel.send(msg);
}
if (message.author.id === "96651399605006336" && message.content === (prefix + "toggleDoggy")) {
let msg = "Doggy is now: ";
if (doggy == true) {
doggy = false;
msg += "false!";
}
else if (doggy == false) {
doggy = true;
msg += "true!";
}
message.channel.send(msg);
}
if (message.author.id === "96651399605006336" && message.content === (prefix + "toggleRock")) {
let msg = "Rock is now: ";
if (rock == true) {
rock = false;
msg += "false!";
}
else if (rock == false) {
rock = true;
msg += "true!";
}
message.channel.send(msg);
}
// If message doesn't start with the prefix.
if (!message.content.startsWith(prefix)) return;
// If message is send from a bot.
if (message.author.bot) return;
// All custom commands
switch (message.content) {
case (prefix + "help"):
const embedHelp = new Discord.RichEmbed();
embedHelp.setAuthor('Commands');
for (var i = 0; i < commandList.length; i++) {
embedHelp.addField(commandList[i][0], commandList[i][1]);
}
message.channel.send(embedHelp);
console.log("Command 'help' executed!");
break;
case (prefix + "rules"):
var rulesString = "__**Rules:**__\n";
var tempString = "";
for (var i = 0; i < rulesList.length; i++) {
tempString = (i+1) + ") " + rulesList[i] + "\n";
rulesString += tempString;
}
message.channel.send(rulesString);
console.log("Command 'rules' executed!");
break;
case (prefix + "subcount"):
request({
uri: `https://www.googleapis.com/youtube/v3/channels/?forUsername=${ytUser}&part=statistics&key=${process.env.API_KEY}`,
json:true }, (err, res, body) => {
if (err) return console.log(err);
message.channel.send("The subscriber count is:\n**" + body.items[0].statistics.subscriberCount + "**");
});
console.log("Command 'subcount' executed!");
break;
case (prefix + "viewcount"):
request({
uri: `https://www.googleapis.com/youtube/v3/channels/?forUsername=${ytUser}&part=statistics&key=${process.env.API_KEY}`,
json:true }, (err, res, body) => {
if (err) return console.log(err);
message.channel.send("The view count is:\n**" + body.items[0].statistics.viewCount + "**");
console.log("Command 'viewcount' executed!")
});
break;
case (prefix + "membercount"):
message.channel.send("The member count is:\n**" + message.guild.memberCount + "**");
console.log("Command 'membercount' executed!");
break;
case (prefix + "texteffects"):
var textString = "__**Text-Effects**__\n";
var tempString = "```\n";
textString += tempString;
for (var i = 0; i < textList.length; i++) {
tempString = textList[i] + "\n";
textString += tempString;
}
textString += "```\n";
for (var i = 0; i < textList.length; i++) {
tempstring = textList[i] + "\n";
textString += tempstring;
}
message.channel.send(textString);
console.log("Command 'texteffects' executed!");
break;
case (prefix + "staff"):
// var staffString = "__**Staff:**__\n";
// var tempString = "";
//
// for (var i = 0; i < staffRoles.length; i++) {
//
// var staffMembers = message.guild.roles.find("name", staffRoles[i]).members;
// var max = staffMembers.size;
// for (var j = 0; j < max; j++) {
// tempString = "**" + staffRoles[i] + "**: " + staffMembers.first().displayName + "\n";
// staffMembers.delete(staffMembers.firstKey());
// staffString += tempString;
// }
// }
// const embedStaff = new Discord.RichEmbed();
// embedStaff.setAuthor('Staff');
//
// var staffMembers = new Map();
// var staff = new Array();
//
// for (var i = 0; i < staffRoles.length; i++) {
// staff.push(new Set());
// console.log(staffRoles[i]);
// var items = message.guild.roles.find('name', staffRoles[i]);
// if (items.length > 0) {
// items = items.members;
// }
// for (var item in items) {
// staffMembers.set(item.displayName, staffRoles[i]);
// }
// }
//
// staffMembers.forEach(function(value, key) {
// for (var i = 0; i < staffRoles.length; i++) {
// if (value == staffRoles[i]) {
// staff[i].add(key);
// }
// }
// });
//
// for (var i = staff.length-1; i >= 0; i--) {
// for (item of staff[i]) {
// embedStaff.addField(staffRoles[i], item);
// }
// }
//
// message.channel.send(embedStaff);
// message.channel.send(staffString);
console.log("Command 'staff' executed!");
break;
case (prefix + "memes"):
message.reply("Be careful with what you post. You are responsible for the contents of your post. If you post an image and the content of it is against the rules, then you will be the one responsible for it.");
console.log("Command 'memes' executed!");
break;
case (prefix + "youtube"):
message.reply("You can find SmashGaming's youtube channel here:\nhttps://www.youtube.com/user/SmashGaming999");
console.log("Command 'youtube' executed!");
break;
case (prefix + "steam"):
message.reply("Join our steam group on:\nhttp://steamcommunity.com/groups/SmashGmainG");
console.log("Command 'steam' executed!");
break;
case (prefix + "twitter"):
message.reply("Check my twitter on:\nhttps://twitter.com/Frazzz101");
console.log("Command 'twitter' executed!");
break;
case (prefix + "patreon"):
message.reply("Check my patreon on:\nhttps://www.patreon.com/smashgaming999");
console.log("Command 'patreon' executed!");
break;
case (prefix + "discord"):
message.reply("Join us on discord:\nhttps://discord.gg/zwEVdFE");
console.log("Command 'discord' executed!");
break;
case (prefix + "facebook"):
message.reply("Find us on Facebook:\nhttps://www.facebook.com/SmashGaming999/");
console.log("Command 'facebook' executed!");
break;
case (prefix + "twitch"):
message.reply("Check out my Twitch on:\nhttps://www.twitch.tv/smashgamingfrazzz");
console.log("Command 'twitch' executed!");
break;
case (prefix + "links"):
const embedLinks = new Discord.RichEmbed();
embedLinks.setColor('e88317');
embedLinks.setAuthor('SmashGaminG!! Links');
embedLinks.addField('Youtube', 'https://www.youtube.com/user/SmashGaming999');
embedLinks.addField('Twitch', 'https://www.twitch.tv/smashgamingfrazzz');
embedLinks.addField('Patreon', 'https://www.patreon.com/smashgaming999');
embedLinks.addField('Merch', 'https://www.redbubble.com/people/SmashGaminG/shop');
embedLinks.addField('Humble partner', 'https://www.humblebundle.com/store?partner=smashgaming');
embedLinks.addField('Youtube Sponsoring', 'https://goo.gl/qZYGxk');
embedLinks.addField('Steam', 'http://steamcommunity.com/groups/SmashGmainG');
embedLinks.addField('Twitter', 'https://twitter.com/Frazzz101');
embedLinks.addField('Facebook', 'https://www.facebook.com/SmashGaming999/');
embedLinks.addField('Instagram', 'https://www.instagram.com/smash_gaming_frazzz/');
embedLinks.addField('Discord', 'https://discord.gg/zwEVdFE');
message.channel.send(embedLinks);
break;
case (prefix + "store"):
case (prefix + "shop"):
case (prefix + "merch"):
message.reply("Check out my awesome merch:\nhttps://www.redbubble.com/people/SmashGaminG/shop");
console.log("Command 'store', 'shop', 'merch' executed!");
break;
default:
var cmd = message.content.substr(0,message.content.indexOf(' '));
var arg = message.content.substr(message.content.indexOf(' ')+1);
if (cmd === (prefix + "searchVid")) {
request({
uri: `https://www.googleapis.com/youtube/v3/search/?part=snippet&channelId=UCfYQJa2qGuCy6z87UBHhA8A&order=date&type=video&key=${process.env.API_KEY}&q=${arg}`,
json:true }, (err, res, body) => {
if (err) return console.log(err);
if (body.items[0] !== undefined) {
message.channel.send("**" + body.items[0].snippet.title + "**\nhttps://www.youtube.com/watch?v=" + body.items[0].id.videoId);
console.log("Command 'searchVid' executed!")
}
else {
message.channel.send("The video could not be found.");
}
});
}
break;
}
});
client.login(process.env.BOT_TOKEN);