Skip to content

Commit 11bea53

Browse files
committed
New commands, vineboom brackets added
1 parent 0c84f58 commit 11bea53

10 files changed

Lines changed: 390 additions & 35 deletions

File tree

server-src/commands.js

Lines changed: 155 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class CommandHandler {
99

1010
var addCommand = this.addCommand.bind(this); //API to add a command.
1111
var sendFeedbackLocal = this.sendFeedbackLocal.bind(this); //Send command feedback locally to client.
12+
var sendFeedbackLocalWithName = this.sendFeedbackLocalWithName.bind(this); //Send command feedback locally to client.
1213
var sendFeedbackGlobal = this.sendFeedbackGlobal.bind(this); //Send command feedback globally to client.
14+
var sendFeedbackGlobalWithName = this.sendFeedbackGlobalWithName.bind(this); //Send command feedback globally to client.
1315
var getUserInfo = this.getUserInfo.bind(this); //Get small user information.
1416
var searchUsersByKey = this.searchUsersByKey.bind(this); //Search users by their username or by @ symbol.
1517
var sendClientCommand = this.sendClientCommand.bind(this); //Send a browser based command to the user.
@@ -35,12 +37,12 @@ class CommandHandler {
3537
function (args, userInfo, senderClient) {
3638
sendFeedbackLocal(
3739
senderClient,
38-
"The new command for all listed commands is ;help",
40+
"The new command for all listed commands is ;help"
3941
);
4042
_this.doCommand(["help"], senderClient); //Run help command as the sender.
4143
},
4244
"Just a placeholder command, it only tells the person using it to use the help command.",
43-
false,
45+
false
4446
);
4547

4648
//This is a useful command, but is separated because yes:
@@ -58,14 +60,14 @@ class CommandHandler {
5860
) {
5961
sendFeedbackLocal(
6062
senderClient,
61-
`[bold][color css=yellow];${commandName}[/color][/bold] - ${_this.commandHelp[commandName]}`,
63+
`[bold][color css=yellow];${commandName}[/color][/bold] - ${_this.commandHelp[commandName]}`
6264
);
6365
} else {
6466
sendFeedbackLocal(
6567
senderClient,
6668
'Help was unable to find command "' +
6769
commandName +
68-
'". You must mention this command in its proper case.',
70+
'". You must mention this command in its proper case.'
6971
);
7072
}
7173
return;
@@ -89,7 +91,7 @@ class CommandHandler {
8991
sendFeedbackLocal(senderClient, text);
9092
},
9193
"<Command Name (Not required)>[br]Gives you the list of commands, or type the command name as the first argument for it.",
92-
false,
94+
false
9395
);
9496

9597
//Useful commands:
@@ -100,7 +102,7 @@ class CommandHandler {
100102
wss._rrRefreshRoom(); //Random rants + has special properties assigned to client and the room websocket server.
101103
},
102104
"Restarts the room, this will clear all the messages.",
103-
true,
105+
true
104106
);
105107

106108
addCommand(
@@ -123,7 +125,7 @@ class CommandHandler {
123125
});
124126
},
125127
"<Username> <Command>[br]Runs the following command as someone else (as the sender) or multiple people.[br]This should [bold]n o t[/bold] be very annoying.",
126-
true,
128+
true
127129
);
128130

129131
addCommand(
@@ -136,7 +138,7 @@ class CommandHandler {
136138
});
137139
},
138140
"<Username> <Message>[br]Shows a popup to the user's browser saying the message provided.",
139-
true,
141+
true
140142
);
141143

142144
addCommand(
@@ -149,7 +151,7 @@ class CommandHandler {
149151
});
150152
},
151153
"<Username>[br]Kick out the specified user from the room.",
152-
true,
154+
true
153155
);
154156

155157
addCommand(
@@ -161,7 +163,7 @@ class CommandHandler {
161163
});
162164
},
163165
"<Username>[br]Freezes the UI temporarily for the user.",
164-
true,
166+
true
165167
);
166168

167169
addCommand(
@@ -172,7 +174,7 @@ class CommandHandler {
172174
if (!/^https?:\/\//.test(url)) {
173175
sendFeedbackLocal(
174176
senderClient,
175-
"URL must start with http:// or https://",
177+
"URL must start with http:// or https://"
176178
);
177179
return;
178180
}
@@ -181,7 +183,36 @@ class CommandHandler {
181183
});
182184
},
183185
"<Username> <URL>[br]Redirects the user to a new page.",
184-
true,
186+
true
187+
);
188+
189+
addCommand(
190+
"broadcast",
191+
function (args, userInfo, senderClient) {
192+
var foundClients = searchUsersByKey(args[0], senderClient);
193+
var message = args.slice(1, args.length).join(" ");
194+
sendFeedbackGlobalWithName(message, "[Notice]");
195+
},
196+
"<Message>[br]Broadcasts a message with the [bold][Notice][/bold] name",
197+
true
198+
);
199+
200+
addCommand(
201+
"nickname",
202+
function (args, userInfo, senderClient) {
203+
var foundClients = searchUsersByKey(args[0], senderClient);
204+
var newName = args.slice(1, args.length).join(" ");
205+
var renamed = false;
206+
foundClients.forEach((client) => {
207+
renamed = true;
208+
client._rrRenameDisplayName(newName);
209+
sendFeedbackGlobal(
210+
`[bold]${client._rrUsername}[/bold]'s display name was temporarily changed to "[bold]${newName}[/bold]".`
211+
);
212+
});
213+
},
214+
"<Username> <New Display Name>[br]Changes display name for that user only for that room, or until they rejoin",
215+
true
185216
);
186217

187218
//Joke commands:
@@ -197,7 +228,7 @@ class CommandHandler {
197228
});
198229
},
199230
"Ballz",
200-
true,
231+
true
201232
);
202233

203234
addCommand(
@@ -209,7 +240,7 @@ class CommandHandler {
209240
});
210241
},
211242
"Run it, and it will explain it all",
212-
true,
243+
true
213244
);
214245

215246
addCommand(
@@ -218,7 +249,7 @@ class CommandHandler {
218249
sendClientCommand(senderClient, "spin");
219250
},
220251
"Spinny spin spin!",
221-
false,
252+
false
222253
);
223254

224255
addCommand(
@@ -227,7 +258,7 @@ class CommandHandler {
227258
sendClientCommand(senderClient, "popcat", args[0]);
228259
},
229260
"<Seconds>[br]Pop pop pop pop pop",
230-
true,
261+
true
231262
);
232263

233264
addCommand(
@@ -239,7 +270,7 @@ class CommandHandler {
239270
});
240271
},
241272
"<Username> <Intensity>[br]Gives the username typed a screen shake.",
242-
true,
273+
true
243274
);
244275

245276
addCommand(
@@ -251,7 +282,7 @@ class CommandHandler {
251282
});
252283
},
253284
"<Username>[br]Flashes the screen background for a moment.",
254-
true,
285+
true
255286
);
256287

257288
addCommand(
@@ -260,7 +291,7 @@ class CommandHandler {
260291
sendClientCommand(senderClient, "funni");
261292
},
262293
"XD",
263-
true,
294+
true
264295
);
265296

266297
addCommand(
@@ -275,7 +306,7 @@ class CommandHandler {
275306
});
276307
},
277308
"<Username>[br]Yipee!",
278-
false,
309+
false
279310
);
280311

281312
addCommand(
@@ -287,7 +318,7 @@ class CommandHandler {
287318
});
288319
},
289320
'Triggers a "dramatic" DOOM countdown on everyone\'s screen.',
290-
false,
321+
false
291322
);
292323

293324
addCommand(
@@ -299,7 +330,7 @@ class CommandHandler {
299330
});
300331
},
301332
"Enjoy your free trial!",
302-
false,
333+
false
303334
);
304335

305336
addCommand(
@@ -311,7 +342,73 @@ class CommandHandler {
311342
});
312343
},
313344
"<Username>[br]Summons a bunch of fake errors and does BSOD on the username.",
314-
true, //Should be owner only because it could be laggy to inactive users when the errors start to stack up.
345+
true //Should be owner only because it could be laggy to inactive users when the errors start to stack up.
346+
);
347+
348+
addCommand(
349+
"vineboom",
350+
function (args, userInfo, senderClient) {
351+
var allClients = getActiveClients();
352+
allClients.forEach((otherClient) => {
353+
sendClientCommand(otherClient, "vineboom");
354+
});
355+
},
356+
"Plays vineboom on everyone's device",
357+
true
358+
);
359+
360+
addCommand(
361+
"MichealWave",
362+
function (args, userInfo, senderClient) {
363+
var allClients = getActiveClients();
364+
var randomClient =
365+
allClients[Math.floor(Math.random(allClients.length - 1))];
366+
sendClientCommand(randomClient, "breakdance");
367+
},
368+
"Shows a microwave breakdancing on someones screen, small in a random spot, and teleports around the screen every 1/2 seconds and keeps doing that until the user clicks him or after 30 seconds.",
369+
true
370+
);
371+
372+
addCommand(
373+
"mildlyInfuriating",
374+
function (args, userInfo, senderClient) {
375+
var foundClients = searchUsersByKey(args[0], senderClient);
376+
foundClients.forEach((otherClient) => {
377+
sendClientCommand(otherClient, "slowrotate");
378+
});
379+
},
380+
"<Username>[br]Makes the specified users screen veeeeeeeeeery slowly start rotating to the left. VEEEEEEEEEEEEERY slow so that eventually they’ll start to realize their screen is a bit off",
381+
true
382+
);
383+
addCommand(
384+
"align",
385+
function (args, userInfo, senderClient) {
386+
var foundClients = searchUsersByKey(args[0], senderClient);
387+
foundClients.forEach((otherClient) => {
388+
sendClientCommand(otherClient, "slowrotateEnd");
389+
});
390+
},
391+
"<Username>[br]Aligns the specified users screen back to its default position from the mildly infuriating command, this command won’t show in the ;help list",
392+
true
393+
);
394+
addCommand(
395+
"importantMessage",
396+
function (args, userInfo, senderClient) {
397+
var foundClients = searchUsersByKey(args[0], senderClient);
398+
var message = args.slice(1, args.length).join(" ");
399+
if (message.trim().length < 1) {
400+
sendFeedbackLocal(
401+
otherClient,
402+
"Message needs to be at least one character."
403+
);
404+
return;
405+
}
406+
foundClients.forEach((otherClient) => {
407+
sendClientCommand(otherClient, "importantMessage", message);
408+
});
409+
},
410+
"<Username> <Message>[br]Makes the screen of the target empty (besides like the background color) except for a small black box like a spoiler on discord and if you click it it slowly fades out and reveals a message, then after a second it returns the screen back to normal like nothing happened.",
411+
true
315412
);
316413

317414
////////////////////////////////////////////////////
@@ -324,7 +421,7 @@ class CommandHandler {
324421
type: "commandToClient",
325422
cType: type,
326423
args,
327-
}),
424+
})
328425
);
329426
}
330427

@@ -355,17 +452,17 @@ class CommandHandler {
355452
await this.commands[commandName](
356453
args.slice(1),
357454
this.getUserInfo(client),
358-
client,
455+
client
359456
);
360457
} catch (e) {
361458
console.log(
362-
`[Command warning]: Command ${commandName} failed with error ${e}`,
459+
`[Command warning]: Command ${commandName} failed with error ${e}`
363460
);
364461
}
365462
} else {
366463
this.sendFeedbackLocal(
367464
client,
368-
`Unable to find command "${commandName}". Remember commands are case sensitive.`,
465+
`Unable to find command "${commandName}". Remember commands are case sensitive.`
369466
);
370467
}
371468
}
@@ -418,7 +515,7 @@ class CommandHandler {
418515
return otherClients;
419516
}
420517

421-
if (lowercaseKey == "@me") {
518+
if (lowercaseKey == "@me" || lowercaseKey == "@self") {
422519
//Only the sender, better than typing your username.
423520
return [senderClient];
424521
}
@@ -483,7 +580,20 @@ class CommandHandler {
483580
message: message,
484581
isServer: true,
485582
displayName: "[Commands]",
486-
}),
583+
})
584+
);
585+
}
586+
}
587+
588+
sendFeedbackLocalWithName(client, message, name) {
589+
if (client._rrIsReady) {
590+
client.send(
591+
JSON.stringify({
592+
type: "newMessage",
593+
message: message,
594+
isServer: true,
595+
displayName: name,
596+
})
487597
);
488598
}
489599
}
@@ -497,7 +607,22 @@ class CommandHandler {
497607
message: message,
498608
isServer: true,
499609
displayName: "[Commands]",
500-
}),
610+
})
611+
);
612+
}
613+
}
614+
}
615+
616+
sendFeedbackGlobalWithName(message, name) {
617+
for (var client of this.wss.clients) {
618+
if (client._rrIsReady) {
619+
client.send(
620+
JSON.stringify({
621+
type: "newMessage",
622+
message: message,
623+
isServer: true,
624+
displayName: name,
625+
})
501626
);
502627
}
503628
}

0 commit comments

Comments
 (0)