-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
428 lines (397 loc) · 13.8 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
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
const Snake = require('./snake');
const Parser = require('./parser');
const Convo = require('./parser');
const http = require('http')
const fs = require('fs')
const Discord = require('discord.js');
const myIntents = new Discord.Intents(8);
myIntents.add(
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.DIRECT_MESSAGE_TYPING,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS
);
const client = new Discord.Client({ intents: myIntents });
const parse = new Parser()
const convo = new Convo()
games = new Map()
var cleaningChannel;
var cleaningCount=0
var tester = false
var isStuck=false
var isOn=false
var activity=120
var counterActions = 0
var debug = false
const server = http.createServer((req, res) => {
res.writeHead(200, { 'content-type': 'text/html' })
fs.createReadStream('index.html').pipe(res)
})
server.listen(8080)
client.on('messageReactionAdd', (reaction, user) => {
console.log(reaction)
try{
if(user.id!=reaction.message.author.id){
if (games.get(user.username)){
game = games.get(user.username)
if (reaction.message===game.displayMessage) {
if (reaction.emoji.name=="⬆️") {
if (game.lastLetter != 's') {
game.lastLetter = 'w'
game.gameTick("up", reaction.message);
}
}
if (reaction.emoji.name=="⬅️") {
if (game.lastLetter != 'd') {
game.lastLetter = 'a'
game.gameTick("left", reaction.message);
}
}
if (reaction.emoji.name=="⬇️") {
if (game.lastLetter != 'w') {
game.lastLetter = 's'
game.gameTick("down", reaction.message);
}
}
if (reaction.emoji.name=="➡️") {
if (game.lastLetter != 'a') {
game.lastLetter = 'd'
game.gameTick("right", reaction.message);
}
}
}
}
}
}catch{
}
});
client.on("messageCreate", (message) => {try{
let aboutNecro = false
if(message.content.toLowerCase().includes("butter")){
aboutNecro=true
}
try{
let user = client.users.cache.find(user => user.username == message.content.split(" ").shift().join(' '))
message.guild.members.fetch(user.id).then(member => {
if(member.roles.cache.some(role => role.name === 'Necromancy')){
aboutNecro=true
};
everything(message,aboutNecro)
})
}catch(error){
everything(message,aboutNecro)
}
// console.log(message)
}catch{
}
});
function everything(message, aboutNecro){
if(message.author.username=="Thyme" && message.content.toLowerCase().startsWith("!overide")){
message.delete()
setTimeout(() => process.abort(), 1000)
}
if(message.author.username=="Thyme" && message.content.toLowerCase().startsWith("!debug")){
message.delete()
debug=true
}
if(message.author.username=="Thyme" && message.content.toLowerCase().startsWith("!undebug")){
message.delete()
debug=false
}
if(message.author.username=="Thyme" && message.content.toLowerCase().startsWith("!test452")){
if(tester){
message.channel.send("The program has stayed up since the last time")
}else{
message.channel.send("It has gone down")
}
message.delete()
tester=true
}
if(message.author.username!="Necromancy's Roomba Snek"){
if(message.content.toLowerCase().startsWith("!help")){
message.channel.send("!snek (you can add parameters by typing control mode: display mode: or size: then typing immeditelly after it an appropriate parameter. For control mode you can enter either reaction or message, for display mode you can enter either newMessage, or editMessage, for size you can enter any number)\n!power on\n!power off\n !unstuck\nAttacks (type a command then someone to attack them):\n- !stab\n- !knife\n- !dagger\n- !shoot\n- !gun")
}
if (message.content.toLowerCase().includes("!hi")||message.content.includes("!hello")) {
possibleStatements = [
"hello :]",
"hello!",
"hello, " + message.author.username,
"hi :]",
"hi!",
"hi, "+ message.author.username+ "!"]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
message.channel.send(possibleStatements[num])
}
if(message.content.toLowerCase().startsWith("!power on")){
if(!isOn){
isOn=true
activity=500
cleaningChannel = message.channel
beginCleaning()
}else{
message.channel.send("This roomba is already on somewhere")
}
}
if(message.content.toLowerCase().startsWith("!power off")){
isOn=false
activity=100000000000000000
message.channel.send("Shutting down :[")
}
if(message.content.toLowerCase().startsWith("!unstuck")){
if(isStuck){
unstuck()
}
else{
message.channel.send("I was already unstuck")
}
}
if(message.content.toLowerCase().startsWith("!shoot")){
if(canAttack(message)){
if(message.content.split("!shoot ")[1]){
if(!(message.member.roles.cache.some(role => role.name === 'Necromancy')) ||message.content.toLowerCase().includes("thyme") || message.content.toLowerCase().includes("thy.me")){
message.channel.send("No")
}else{
message.channel.send( message.content.split("!shoot ")[1]+" 🔫")
}
}else{
message.channel.send("🔫 ")
}
}
}
if(message.content.toLowerCase().startsWith("!gun")){
if(canAttack(message)){
if(message.content.split("!gun ")[1]){
if(aboutNecro || !(message.member.roles.cache.some(role => role.name === 'Necromancy')) ||message.content.toLowerCase().includes("thyme") || message.content.toLowerCase().includes("thy.me")){
message.channel.send("No")
}else{
message.channel.send(message.content.split("!gun ")[1]+" 🔫")
}
}else{
message.channel.send("🔫 ")
}
}
}
if(message.content.toLowerCase().startsWith("!knife")){
if(canAttack(message)){
if(message.content.split("!knife ")[1]){
if(aboutNecro || !(message.member.roles.cache.some(role => role.name === 'Necromancy')) ||message.content.toLowerCase().includes("thyme") || message.content.toLowerCase().includes("thy.me")){
message.channel.send("No")
}else{
message.channel.send("🔪 " + message.content.split("!knife ")[1])
}
}else{
message.channel.send("🔪 ")
}
}
}
if(message.content.toLowerCase().startsWith("!stab")){
if(canAttack(message)){
if(message.content.split("!stab ")[1]){
if(aboutNecro || !(message.member.roles.cache.some(role => role.name === 'Necromancy')) ||message.content.toLowerCase().includes("thyme") || message.content.toLowerCase().includes("thy.me")){
message.channel.send("No")
}else{
message.channel.send("🔪 " + message.content.split("!stab ")[1])
}
}else{
message.channel.send("🔪 ")
}
}
}
if(message.content.toLowerCase().startsWith("!dagger")){
if(canAttack(message)){
if(message.content.split("!dagger ")[1]){
if(aboutNecro || !(message.member.roles.cache.some(role => role.name === 'Necromancy')) ||message.content.toLowerCase().includes("thyme") || message.content.toLowerCase().includes("thy.me")){
message.channel.send("No")
}else{
message.channel.send(message.content.split("!dagger ")[1]+" 🗡️")
}
}else{
message.channel.send("🗡 ")
}
}
}
if (message.content.toLowerCase().startsWith("!snek") && !games.get(message.author.username)) {
console.log(games)
console.log(message.content)
var size = parse.getSize(message)
var displayMode = parse.getDisplayMode(message)
var controlMode = parse.getControlMode(message)
games.set(message.author.username, new Snake(message.author.username, size, controlMode, displayMode))
game = games.get(message.author.username)
game.lastLetter = 'w'
game.gameTick("up", message, game);
}
if (games.get(message.author.username)) {
game = games.get(message.author.username)
if (message.content.toLowerCase().charAt(0) == 'w') {
if (game.lastLetter != 's') {
game.lastLetter = 'w'
game.gameTick("up", message);
}
}
if (message.content.toLowerCase().charAt(0) == 'a') {
game = games.get(message.author.username)
if (game.lastLetter != 'd') {
game.lastLetter = 'a'
game.gameTick("left", message);
}
}
if (message.content.toLowerCase().charAt(0) == 's') {
game = games.get(message.author.username)
if (game.lastLetter != 'w') {
game.lastLetter = 's'
game.gameTick("down", message);
}
}
if (message.content.toLowerCase().charAt(0) == 'd') {
game = games.get(message.author.username)
if (game.lastLetter != 'a') {
game.lastLetter = 'd'
game.gameTick("right", message);
}
}
if (message.content.toLowerCase().charAt(1) == 'w') {
game = games.get(message.author.username)
if (game.lastLetter != 's') {
game.lastLetter = 'w'
game.gameTick("up", message);
}
}
if (message.content.toLowerCase().charAt(1) == 'a') {
game = games.get(message.author.username)
if (game.lastLetter != 'd') {
game.lastLetter = 'a'
game.gameTick("left", message);
}
}
if (message.content.toLowerCase().charAt(1) == 's') {
game = games.get(message.author.username)
if (game.lastLetter != 'w') {
game.lastLetter = 's'
game.gameTick("down", message);
}
}
if (message.content.toLowerCase().charAt(1) == 'd') {
game = games.get(message.author.username)
if (game.lastLetter != 'a') {
game.lastLetter = 'd'
game.gameTick("right", message);
}
}
if (message.content.toLowerCase().startsWith("!restart") || message.content.startsWith("!stop")) {
game = games.get(message.author.username)
games.delete(game.id);
console.log("Game Stopped");
message.channel.send("**Game Stopped!**");
}
if (game.displayMode == "editMessage") {
message.delete()
}
}
}
}
client.login(process.env['token']);
function clean(){
cleaningCount++
var state=Math.floor(Math.random()*100)
if(cleaningCount>8 ||state<10){
doneCleaning()
//finish cleaning
}else if(state<55){
stuck()
//stuck
}else{
//continue cleaning
continueCleaning()
}
}
function stuck(){
isStuck=true
console.log("stuck")
possibleStatements = [
"Oh no! I'm trapped :[ please use !unstuck to get me out!",
"Uh oh! I'm stuck in this corner. Can you please get me out with !unstuck?",
"spin spin spin spin spin I can't spin my way out of here! Can someone help me by using !unstuck"]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
cleaningChannel.send(possibleStatements[num])
}
function unstuck(count){
isStuck=false
console.log("unstuck")
possibleStatements = [
"Thanks!",
"Thank you :]"]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
cleaningChannel.send(possibleStatements[num])
var time = (Math.random()*2*1500+2*750)*activity;
setTimeout(clean,time);
}
function beginCleaning(channel){
possibleStatements = [
"hello! I am here to clean up the chat :]",
"I'm going to clean the chat now :]",
"Starting cleaning process!",
"It's time for me to clean!"
]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
cleaningChannel.send(possibleStatements[num])
var time = (Math.random()*2*1500+2*750)*activity
if(debug){
cleaningChannel.send(time.toString());
}
setTimeout(clean,time);
}
function continueCleaning(count,channel){
console.log("continueCleaning")
possibleStatements = [
"room vroom",
"spins around",
"let me clean up this dust for you :]",
"(runs into a wall) AAAAAAAAAAA",
"(bumps into a chair) aaaaaaaAAAAAAAAAA",
"(hits a door) OW! ow ow ow ow ow",
"(bumps into a wall) AAGH! not AGAIN",
"beep beep!",
"coming through!",
"excuse me!"]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
cleaningChannel.send(possibleStatements[num])
var time = (Math.random()*2*1500+2*750)*activity
if(debug){
cleaningChannel.send(time.toString());
}
setTimeout(clean,time);
}
function doneCleaning(channel){
console.log("doneCleaning")
possibleStatements = [
"All done cleaning!",
"I'm finished cleaning :]",
]
var num = Math.floor(Math.random()*possibleStatements.length)
console.log(possibleStatements[num])
cleaningChannel.send(possibleStatements[num])
var time = (Math.random()*2*1500+4*1500)*activity
if(debug){
cleaningChannel.send(time.toString());
}
console.log(time)
setTimeout(beginCleaning,time);
}
function canAttack(message){
if(message.member.roles.cache.some(role => role.name == 'Necromancy')){
return true
}else{
message.channel.send("No, Weapons are only for Necromancy")
return false
}
}