-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timebomb (CC)
585 lines (535 loc) · 31.2 KB
/
Timebomb (CC)
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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
{//; BLARGBOT TIMEBOMB COMMAND
* Created by k6ka#1014
* Code is released under a Creative Commons Attribution-ShareAlike license
* Give credit where credit is due!
* See https://github.com/CzarHey/discord-timebomb for instructions
Version 2.1.2CC dated May 22, 2023
}
{//;Version number}
{void;
{set;~version;2.1.2CC}
{set;~dated;May 22, 2023}
}
{//;Define debugging output, triggered with flag -d.}
{function;debug;
{if;{flagset;d};==;true;{file;Report generated {time;YYYY/MM/DD HH:mm:ss}
Version number: {get;~version} dated {get;~dated}
Command name: {commandname}
Message sender: {messagesender} ({exec;person;{messagesender}})
Server: {guildid} ({guildname})
Is staff: {isstaff}
Is CC: {iscc}
Tag author: {exec;person;{tagauthor}}
Is author staff: {isstaff;{tagauthor}}
Tag authorizer: {exec;person;{tagauthorizer}}
Is authorizer staff: {isstaff;{tagauthorizer}}
User input: {args}
==Variables==
Banlists
~channelBanned: {get;~channelBanned}
~userBanned: {get;~userBanned}
Debug functionality
~canResetVariables: {get;~canResetVariables}
~approveToReset: {get;~approveToReset}
@timebomb-scores-success-guildid-flagt: {get;@timebomb-scores-success-{guildid}-{flag;t}}
@timebomb-scores-fail-guildid-flagt: {get;@timebomb-scores-fail-{guildid}-{flag;t}}
@timebomb-scores-timeout-guildid-flagt: {get;@timebomb-scores-timeout-{guildid}-{flag;t}}
@timebomb-scores-bombs-guildid-flagt: {get;@timebomb-scores-bombs-{guildid}-{flag;t}}
@timebomb-scores-streak-guildid-flagt: {get;@timebomb-scores-streak-{guildid}-{flag;t}}
@timebomb-scores-streakrecord-guildid-flagt: {get;@timebomb-scores-streakrecord-{guildid}-{flag;t}}
Bomb variables
~currentTimeMinusLastTime: {get;~currentTimeMinusLastTime}
~canBombUser: {get;~canBombUser}
@timebomb-lastBombTime-guildid-userid: {get;@timebomb-lastBombTime-{guildid}-{userid}}
~victim: {get;~victim}
~victimType: {get;~victimType}
~wireColor: {get;~wireColor}
~wireColorText: {get;~wireColorText}
~msgEmoji: {get;~msgEmoji}
~msgColor: {get;~msgColor}
~msgTitle: {get;~msgTitle}
~msgText: {get;~msgText}
~msgFooter: {get;~msgFooter}
~msgID: {get;~msgID}
~reaction: {get;~reaction}
~result: {get;~result}
@timebomb-scores-success-guildid-victim: {get;@timebomb-scores-success-{guildid}-{get;~victim}}
@timebomb-scores-fail-guildid-victim: {get;@timebomb-scores-fail-{guildid}-{get;~victim}}
@timebomb-scores-timeout-guildid-victim: {get;@timebomb-scores-timeout-{guildid}-{get;~victim}}
@timebomb-scores-bombs-guildid-userid: {get;@timebomb-scores-bombs-{guildid}-{userid}}
@timebomb-scores-streak-guildid-victim: {get;@timebomb-scores-streak-{guildid}-{get;~victim}}
@timebomb-scores-streakrecord-guildid-victim: {get;@timebomb-scores-streakrecord-{guildid}-{get;~victim}}
~timeLeftToBomb: {get;~timeLeftToBomb}
Scores variables
~scoresUser: {get;~scoresUser}
@timebomb-scores-success-guildid-scoresUser: {get;@timebomb-scores-success-{guildid}-{flag;t}}
@timebomb-scores-fail-guildid-scoresUser: {get;@timebomb-scores-fail-{guildid}-{flag;t}}
@timebomb-scores-timeout-guildid-scoresUser: {get;@timebomb-scores-timeout-{guildid}-{flag;t}}
@timebomb-scores-bombs-guildid-scoresUser: {get;@timebomb-scores-bombs-{guildid}-{flag;t}}
@timebomb-scores-streak-guildid-scoresUser: {get;@timebomb-scores-streak-{guildid}-{flag;t}}
@timebomb-scores-streakrecord-guildid-scoresUser: {get;@timebomb-scores-streakrecord-{guildid}-{flag;t}}
@timebomb-scores-success-guildid-total: {get;@timebomb-scores-success-{guildid}-total}
@timebomb-scores-fail-guildid-total: {get;@timebomb-scores-fail-{guildid}-total}
@timebomb-scores-timeout-guildid-total: {get;@timebomb-scores-timeout-{guildid}-total}
@timebomb-scores-bombs-guildid-total: {get;@timebomb-scores-bombs-{guildid}-total}
@timebomb-scores-streak-guildid-total: {get;@timebomb-scores-streak-{guildid}-total}
@timebomb-scores-streakrecord-guildid-total: {get;@timebomb-scores-streakrecord-{guildid}-total}
@timebomb-scores-success-global-total: {get;@timebomb-scores-success-global-total}
@timebomb-scores-fail-global-total: {get;@timebomb-scores-fail-global-total}
@timebomb-scores-timeout-global-total: {get;@timebomb-scores-timeout-global-total}
@timebomb-scores-bombs-global-total: {get;@timebomb-scores-bombs-global-total}
@timebomb-scores-streak-global-total: {get;@timebomb-scores-streak-global-total}
@timebomb-scores-streakrecord-global-total: {get;@timebomb-scores-streakrecord-global-total};timebomb_debug_output-{time;YYYYMMDDTHHmmss}.txt}
}
}
{//;Scores output, generated by flag -s}
{if;{flagset;s};==;true;
{//;Check user input.}
{if;{length;{flag;s}};>;0;
{set;~scoresUser;{suppresslookup}{userid;{flag;s}}}
{if;{get;~scoresUser};==;`No user found`;{//;
If user isn't found, display an error message
}❌ | Oops! {usermention}, either I couldn't find the specified user in this server, or you cancelled the query! Here are some things you can try:{newline}{//;
}• Mention the user instead of typing out their username.{newline}{//;
}• Type out the full username, including the user tag.{newline}{//;
}• Use a user ID number instead of the username.{func.debug}
;{//;Else, display the scores}
{output;
{embed;
{embedbuild;
title:🏆 Timebomb Scores for {exec;person;{get;~scoresUser}};
description:{//;
}✅ Number of successful defusals: {if;{get;timebomb-scores-success-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-success-{get;~scoresUser}}}{newline}{//;
}💥 Number of unsuccessful defusals: {if;{get;timebomb-scores-fail-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-fail-{get;~scoresUser}}}{newline}{//;
}⏲️ Number of timeouts: {if;{get;timebomb-scores-timeout-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-timeout-{get;~scoresUser}}}{newline}{//;
}💣 Number of bombs thrown: {if;{get;timebomb-scores-bombs-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-bombs-{get;~scoresUser}}}{newline}{//;
}🌩️ Current winning streak: {if;{get;timebomb-scores-streak-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-streak-{get;~scoresUser}}}{newline}{//;
}🏅 Highest streak: {if;{get;timebomb-scores-streakrecord-{get;~scoresUser}};==;{//;Empty};0;{get;timebomb-scores-streakrecord-{get;~scoresUser}}}
;
color:{if;{exec;usercolor;{get;~scoresUser}};==;;F7F8F9;{exec;usercolor;{get;~scoresUser}}};
thumbnail.url:{useravatar;{get;~scoresUser}};
footer.icon_url:{useravatar};
footer.text:This command was initiated by {exec;person;{userid}}
}
}
{func.debug}
}
}
;{//;If left blank, display server scores}
{output;
{embed;
{embedbuild;
title:🏆 Timebomb Scores;
description:**Timebomb Scores for {guildname}**{newline;2}{//;
}✅ Number of successful defusals: {if;{get;timebomb-scores-success-total};==;{//;Empty};0;{get;timebomb-scores-success-total}}{newline}{//;
}💥 Number of unsuccessful defusals: {if;{get;timebomb-scores-fail-total};==;{//;Empty};0;{get;timebomb-scores-fail-total}}{newline}{//;
}⏲️ Number of timeouts: {if;{get;timebomb-scores-timeout-total};==;{//;Empty};0;{get;timebomb-scores-timeout-total}}{newline}{//;
}💣 Number of bombs thrown: {if;{get;timebomb-scores-bombs-total};==;{//;Empty};0;{get;timebomb-scores-bombs-total}}{newline}{//;
}🏅 Highest streak: {if;{get;timebomb-scores-streakrecord-total};==;{//;Empty};None yet!;{get;timebomb-scores-streakrecord-total} by {exec;person;{get;timebomb-scores-streakrecord-crown}}};
color:{if;{exec;usercolor;{userid}};==;;F7F8F9;{exec;usercolor;{userid}}};
footer.icon_url:{useravatar};
footer.text:This command was initiated by {exec;person;{userid}};
{if;{guildicon};==;;{//;Do not use thumbnail.url if no guild icon is set, otherwise it will error out};thumbnail.url:{guildicon}{semi}}
}
}
{func.debug}
}
}
{return}{//;Stop the rest of the command from running}
}
{//;Check to see if this is being run as a custom command in a server}
{if;{iscc};{//;If true, run the rest of the command}
{//;Channel banlist—do not allow the command to be used in the listed channels.
Edit the timebomb-channelbanlist command for the list.
}
{set;~channelBanned;{execcc;timebomb-channelbanlist}}
{if;{get;~channelBanned};
{output;❌ | This command has been disabled in this channel by server staff.{func.debug}}{return}
}
{//;User banlist—do not allow the command to be used by the listed users.
Edit the timebomb-userbanlist command for the list.
}
{set;~userBanned;{execcc;timebomb-userbanlist}}
{if;{get;~userBanned};
{output;❌ | Sorry {usermention}, but you are not permitted to use this command. Contact server staff for details.{func.debug}}{return}
}
{//;Check to see if the user left the command blank}
{if;>;{argslength};0;
{//;Reset timebomb-lastBombTime variable if flag -r is set. For debugging purposes only.}
{if;{flagset;r};==;true;
{//;k6ka can reset variables regardless of permissions}
{if;{userid};==;249223024962830338;{set;~canResetVariables;true};
{//;Allow server staff to reset variables}
{if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
}
{if;{get;~canResetVariables};==;true;
{//;Reset variables}
{set;timebomb-lastBombTime-{flag;r};}
{output;✅ | Done, {usermention}! The cooldown timer for {exec;person;{flag;r}} has been reset.{func.debug}};
{output;❌ | Sorry {usermention}, but you don't have permission to do this!{func.debug}}
}
{return}{//;Stop the rest of the command from running}
}
{//;Reset user scores variables if flag -t is set. For debugging purposes only.}
{if;{flagset;t};==;true;
{//;k6ka can reset variables regardless of permissions}
{if;{userid};==;249223024962830338;{set;~canResetVariables;true};
{//;Allow server staff to reset scores}
{if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
}
{if;{get;~canResetVariables};==;true;
{//;Reset scores}
{set;timebomb-scores-success-{flag;t};}
{set;timebomb-scores-fail-{flag;t};}
{set;timebomb-scores-timeout-{flag;t};}
{set;timebomb-scores-bombs-{flag;t};}
{set;timebomb-scores-streak-{flag;t};}
{set;timebomb-scores-streakrecord-{flag;t};}
{output;✅ | Done, {usermention}! The scores for {exec;person;{flag;t}} have been reset.{func.debug}};
{output;❌ | Sorry {usermention}, but you don't have permission to do this!{func.debug}}
}
{return}{//;Stop the rest of the command from running}
}
{//;Reset server scores variables if flag -g is set. For debugging purposes only.}
{if;{flagset;g};==;true;
{//;k6ka can reset variables regardless of permissions}
{if;{userid};==;249223024962830338;{set;~canResetVariables;true};
{//;Allow server staff to reset scores}
{if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
}
{if;{get;~canResetVariables};==;true;
{send;{channelid};⚠️ | **WARNING:** You are about to reset the scores for this server. To protect against accidental use, please enter `I confirm this message` below exactly. This message will expire in 15 seconds.}
{void;
{waitmessage;{channelid};{userid};{set;~approveToReset;{bool;{messagetext};contains;I confirm this message}};15
}
}
{if;{get;~approveToReset};==;true;
{//;Reset scores}
{set;timebomb-scores-success-total;}
{set;timebomb-scores-fail-total;}
{set;timebomb-scores-timeout-total;}
{set;timebomb-scores-bombs-total;}
{set;timebomb-scores-streak-total;}
{set;timebomb-scores-streakrecord-total;}
{set;timebomb-scores-streakrecord-crown;}
{output;✅ | Done, {usermention}! Scores for {guildname} have been reset.{func.debug}}
;{output;❌ | Query cancelled.{func.debug}}
};{output;❌ | Sorry {usermention}, but you don't have permission to do this!{func.debug}}
}
{return}{//;Stop the rest of the command from running}
}
{//;Help output, generated by flag -h}
{if;{flagset;h};==;true;
{output;
{switch;{args;1};
2;{//;Second page}
{embed;
{embedbuild;
title:❓ Timebomb Back-end Help;
description:**__Troubleshooting__**{newline;2}{//;
}• **"blargbot is throwing `No message found` errors."** Make sure the bot has the "Read Message History" permission on the channel.{newline}{//;
}• **"blargbot is throwing `This command was not authorized by server staff` errors."** Reauthorize the command as staff using the specified instructions.{newline}{//;
}• **"blargbot is throwing `I dont have permission to Add Reactions` errors."** Make sure the bot has the "Add Reaction" permission on the channel.{newline}{//;
}• **"Bombed user picks a wire, but no response from the bot."** If the user picks a wire while the bot is still setting up the message, their input will be ignored. They must pick another wire or remove their reaction and try again.{newline}{//;
}• **"Bomb timer supposedly expires but no response from bot."** The bot may have gone down while the command was active. The command will appear to have frozen and no scores will be saved.{newline}{//;
}• **"Command is very slow to execute and throws an `An internal server error has occurred` error before continuing."** There is an issue with the bot's database that prevents the cooldown timer and scores from working. Report the issue on the bot's support server.;
color:e09040;
footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license • Version {get;~version}
}
}
;{//;First page}
{embed;
{embedbuild;
title:❓ Timebomb Back-end Help;
description:**This help document is only for server staff.** If you are looking for general end-user assistance, type `b!{commandname}` without any arguments.{newline;2}{//;
}**__Resetting cooldown timers__**{newline;2}{//;
}Each user has a cooldown timer that limits them to throwing one bomb per minute. Resetting a cooldown timer allows the user to bomb again without having to wait for the timer to expire. To reset a user's cooldown timer, type `b!{commandname} -r <user ID>`.{newline;2}{//;
}**__Resetting scores__**{newline;2}{//;
}You can reset a user's scores or the scoreboard of a server. Resetting a server's scoreboard will not reset the scores of individual users. There is currently no way to reset everyone's scores on all servers all at once.{newline;2}{//;
}• To reset a user's score, type `b!{commandname} -t <user ID>`{newline}{//;
}• To reset the current server's scores, type `b!{commandname} -g`{newline;2}{//;
}**__Debug mode__**{newline;2}{//;
}To enable debug output, use flag `-d` anywhere in the command. The debug output will be provided when the command ends.{newline;2}{//;
}**__GitHub__**{newline;2}{//;
}You can access more help or view the source code of the command on [GitHub](https://github.com/CzarHey/discord-timebomb "github.com/CzarHey/discord-timebomb").{newline;2}{//;
}*Type `b!{commandname} -h 2` to view information about troubleshooting.*;
color:e09040;
footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license • Version {get;~version}
}
}
}
{func.debug}
}
{return}{//;Stop the rest of the command from running}
}
{//;Is staff check.}
{if;{isstaff;{tagauthorizer}};==;false;❌ | This command was not authorized by server staff, or the person who authorized it is no longer staff. Please alert server staff and let them know that someone with these permissions (<https://discordapi.com/permissions.html#8254>) needs to reimport the command.
If you need more help regarding bot permissions, you can ask on the bot's support server: https://discord.gg/015GVxZxI8rtlJgXF
You can also ask {exec;person;249223024962830338}, the author of this command. You can find him on the bot's support server.
{func.debug}{return}
}
{//;Check to see if the user has ever bombed anyone in the past}
{if;{length;{get;timebomb-lastBombTime-{userid}}};>;0;
{//;If true, take the current Unix time and subtract it from the last bomb time}
{set;~currentTimeMinusLastTime;
{math;-;{time;X};{get;timebomb-lastBombTime-{userid}}}
}
{//;If last bomb time was <= 60 seconds ago, do not allow user to bomb. If last bomb time was > 60 seconds ago, allow user to bomb.}
{if;{get;~currentTimeMinusLastTime};>;60;{set;~canBombUser;true};{set;~canBombUser;false}};
{//;If user has never bombed anyone on this server, ever, allow them to bomb}
{set;~canBombUser;true}
}
{//;Check to see if the bomber has bombed someone in the past 60 seconds based on the check above}
{if;{get;~canBombUser};{//;If yes, continue command execution}
{//;Get the victim's user ID and save it for later}
{suppresslookup}{set;~victim;{userid;{args}}}
{//;Validate input—if bomber cancels the query {userid} will return nothing}
{if;{get;~victim};!=;`No user found`;
{//;If ~victim isn't empty, continue}
{//;Get further validation of input—make sure user isn't trying to bomb blargbot, another bot, or themselves.}
{set;~victimType;
{//;Trying to blow up blargy?}{if;{get;~victim};==;134133271750639616;blargy;
{//;Trying to blow up another bot?}{if;{userisbot;{get;~victim}};bot;
{//;Trying to blow up themselves?}{if;{get;~victim};==;{userid};self;
{//;Trying to blow up a user not in server?}{if;{exec;usercheck;{get;~victim}};==;false;absent;
{//;If all checks passed, output valid}valid
}
}
}
}
}
{//;Process those results}
{switch;{get;~victimType};
blargy;❌ | You thought you could trick me into bombing myself, {usermention}?!;
bot;❌ | I'm not bombing one of my own kin, {usermention}! Pick a *human* to blow up.;
self;❌ | Please, {usermention}! Pick a friend if you have to!;
absent;❌ | That user isn't on this server, {usermention}!;
valid;{//;If ~victimType is valid, continue – the user input is valid and we can bomb them}
{//;Set the Unix timestamp of the bombing message for the cooldown timer. Use ! before variable to save to database immediately; this prevents users from bombing again right away.}
{set;!timebomb-lastBombTime-{userid};
{messagetime;
{messageid};X
}
}
{//;Set the wire colour}
{set;~wireColor;{randchoose; 🔴 ; ⚪ ; 🔵 }}
{//;Get the text version of the color}
{set;~wireColorText;
{switch;{get;~wireColor};
🔴 ; red;
⚪ ; white;
🔵 ; blue;
❌ **FATAL ERROR**: No wire color was set!!!
}
}
{//;Generate the message output text that the user is going to see}
{void;
{set;~msgEmoji;💣}
{set;~msgColor;e09040}
{set;~msgTitle;{randchoose;
Bombs Ahoy!;
Fire in the hole!;
I hear a fuse!;
Look out behind you!;
What's that ticking sound?;
Code Red: Bomb Threat!!!
}}
{set;~msgText;
{randchoose;
ね, {usermention;{get;~victim}}, there's a stowaway in your pants! It's a bomb on a one minute timer. There are three wires: red, white, and blue. Click on the colour emoji below to cut that wire and try to defuse the bomb!;
Hey {usermention;{get;~victim}}, someone shoved a bomb down your pants! There's one minute to go on the fuse, and there are three wires: red, white, and blue. Quick, click on the colour emoji below to tell me which wire to cut!;
Watch out, {usermention;{get;~victim}}! There's a bomb strapped to your undies! The timer is set for one minute, and there are three wires: red, white, and blue. Click on the colour emoji below to cut that wire.;
*Achtung!* There's a bomb down your pants, {usermention;{get;~victim}}! There's a one minute fuse on it, and there appears to be three wires: red, white, and blue. Given where it is, you should let me cut one of the wires for you{semi} click on the colour emoji below to tell me which one to cut!;
Hey {usermention;{get;~victim}}, I saw someone put a bomb down your pants. One minute fuse, three wires: red, white, and blue. Time is running out! Click on the colour emoji below to cut that wire.
}
}
{set;~msgFooter;{exec;person;{userid}} bombed you, by the way.}
}
{//;Sends the first message}
{//;Collect the ID of the message the bot sends, and suppresses msgID output from {send}}
{set;~msgID;
{send;{channelid};
{usermention;{get;~victim}};
{embedbuild;
title:{get;~msgEmoji} {get;~msgTitle};
description:{get;~msgText};
color:{get;~msgColor};
footer.icon_url:{useravatar};
footer.text:{get;~msgFooter}
}
}
}
{//;Add the reactions to the message}
{reactadd;{get;~msgID}; 🔴 ; ⚪ ; 🔵 }
{//;DMs the initiating user the colour of the correct wire}
{dm;{userid};🤫 | Hey, don't tell {usernick;{get;~victim}}, but it's the {get;~wireColorText} wire.}
{//; Wait until user reacts one of the emojis provided}
{void;
{waitreaction;{get;~msgID};{userid;{get;~victim}};🔴 ⚪ 🔵 ;{set;~reaction;{reaction}}true;60}
}
{//;Process the reaction. If they picked the right colour, return success. If not, return fail. If they timed out, return timeout.}
{void;
{set;~result;
{switch;{get;~reaction};
🔴 ; {//;User reacted red}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
⚪ ; {//;User reacted white}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
🔵 ; {//;User reacted blue}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
{//;User timed out}timeout
}
}
}
{//;Display either a success, fail, or timeout message}
{switch;{get;~result};
success;
{//;Modify variables}
{set;~msgEmoji;✅}
{set;~msgColor;85b061}
{//;Edit the message}
{edit;{get;~msgID};;
{embedbuild;
title:{get;~msgEmoji} {get;~msgTitle};
description:{get;~msgText}{newline;2}{randchoose;
Success, {usernick;{get;~victim}}! That was the correct wire! You have defused the bomb!;
You did it, {usernick;{get;~victim}}! I'll be honest, I thought you were dead, but you managed to pick the right colour and saved yourself! Nicely done.;
Phew! Nice work, {usernick;{get;~victim}}! You defused the bomb successfully!;
Hey, the ticking sound's gone. Great job, {usernick;{get;~victim}}! You picked the right wire and saved yourself!
};
color:{get;~msgColor};
footer.icon_url:{useravatar};
footer.text:{get;~msgFooter}
}
}
{//;Set scores}
{void;
{//;If the variables are empty (null), fallback to 1 to count first score. This fallback shouldn't apply to things outside of this void tag.}
{fallback;1}
{//;Set user score}
{set;timebomb-scores-success-{get;~victim};{math;+;{get;timebomb-scores-success-{get;~victim}};1}}
{//;Set server score}
{set;timebomb-scores-success-total;{math;+;{get;timebomb-scores-success-total};1}}
{//;Add to user streak score}
{set;timebomb-scores-streak-{get;~victim};{math;+;{get;timebomb-scores-streak-{get;~victim}};1}}
{//;Add to user streak record}
{//;Check if streakrecord is null. It will be null if the user has never had a record.}
{if;{get;timebomb-scores-streakrecord-{get;~victim}};==;;
{//;If null, set the record to one}{set;timebomb-scores-streakrecord-{get;~victim};1};
{//;If not null, check to see if the current streak is higher than the streakrecord}{if;{get;timebomb-scores-streak-{get;~victim}};>;{get;timebomb-scores-streakrecord-{get;~victim}};
{//;If it's higher, set streakrecord to match score-streak}{set;timebomb-scores-streakrecord-{get;~victim};{get;timebomb-scores-streak-{get;~victim}}}
}
}
{//;Add to server streak record}
{//;Check if streakrecord is null. It will be null if the user has never had a record.}
{if;{get;timebomb-scores-streakrecord-total};==;;
{//;If null, set the record to one, and give the crown to that user}{set;timebomb-scores-streakrecord-total;1}{set;timebomb-scores-streakrecord-crown;{get;~victim}};
{//;If not null, check to see if the current streak is higher than the streakrecord}{if;{get;timebomb-scores-streak-{get;~victim}};>;{get;timebomb-scores-streakrecord-total};
{//;If it's higher, set streakrecord to match score-streak}{set;timebomb-scores-streakrecord-total;{get;timebomb-scores-streak-{get;~victim}}}
{//;Note down the victim's user ID as they are the new crown-holder}{set;timebomb-scores-streakrecord-crown;{get;~victim}}
}
}
};
fail;
{//;Modify variables}
{set;~msgEmoji;💥}
{set;~msgColor;ac2d3a}
{//;Edit the message}
{edit;{get;~msgID};;
{embedbuild;
title:{get;~msgEmoji} {get;~msgTitle};
description:{get;~msgText}{newline;2}{randchoose;
Nope, wrong wire, {usernick;{get;~victim}}! Aww, now you've gone and killed yourself. Wow. Sorry.;
Whoops, looks like that wasn't the correct wire, {usernick;{get;~victim}}! Well, now you're dead. Sorry about that.;
Oops! That was the wrong wire, {usernick;{get;~victim}}! Oh great, now the bomb has gone off. RIP.;
The bomb went off and blew {usernick;{get;~victim}} to smithereens! Oh well, I'm sure they'll have better luck next time.;
Uh oh, the bomb's going off! Take cover!!! ...wait, {usernick;{get;~victim}}, the bomb is on YOU! Oh well, I guess you're going to die anyway.;
Aww, tough luck, {usernick;{get;~victim}}. Well, I guess I have to clean up all of the guts in this place.
} (You should have picked the {get;~wireColorText} wire);
color:{get;~msgColor};
footer.icon_url:{useravatar};
footer.text:{get;~msgFooter}
}
}
{//;Set scores}
{void;
{//;If the variables are empty (null), fallback to 1 to count first score. This fallback shouldn't apply to things outside of this void tag.}
{fallback;1}
{//;Set user score}
{set;timebomb-scores-fail-{get;~victim};{math;+;{get;timebomb-scores-fail-{get;~victim}};1}}
{//;Set server score}
{set;timebomb-scores-fail-total;{math;+;{get;timebomb-scores-fail-total};1}}
{//;Reset user streak score}
{set;timebomb-scores-streak-{get;~victim};}
};
timeout;
{//;Modify variables}
{set;~msgEmoji;💥}
{set;~msgColor;ac2d3a}
{//;Edit the message}
{edit;{get;~msgID};;
{embedbuild;
title:{get;~msgEmoji} {get;~msgTitle};
description:{get;~msgText}{newline;2}{randchoose;
Oh come on, {usernick;{get;~victim}}, you could've at least picked something! Well, now you're dead. You see that? Guts everywhere.;
Too slow, {usernick;{get;~victim}}! You were a sitting duck waiting for the bomb to go off. Try to save yourself next time!;
Well, it looks like {usernick;{get;~victim}} failed to pick a wire in time. Their indecisveness sure paid off. With their death!;
Please, {usernick;{get;~victim}}, you could've at least tried! Oh well. Rest in pieces, I guess.;
Hello? Earth to {usernick;{get;~victim}}? You were just bombed! Next time, you should tell me which wire to cut to try to save yourself from annihilation.
} (You should have picked the {get;~wireColorText} wire);
color:{get;~msgColor};
footer.icon_url:{useravatar};
footer.text:{get;~msgFooter}
}
}
{//;Set scores}
{void;
{//;If the variables are empty (null), fallback to 1 to count first score. This fallback shouldn't apply to things outside of this void tag.}
{fallback;1}
{//;Set user score}
{set;timebomb-scores-timeout-{get;~victim};{math;+;{get;timebomb-scores-timeout-{get;~victim}};1}}
{//;Set server score}
{set;timebomb-scores-timeout-total;{math;+;{get;timebomb-scores-timeout-total};1}}
{//;Reset streak score}
{set;timebomb-scores-streak-{get;~victim};}
};
❌ | Uh oh, something went wrong! Please report this error to {exec;person;249223024962830338}!
}
{void;
{//;If the variables are empty (null), fallback to 1 to count first score. This fallback shouldn't apply to things outside of this void tag.}
{fallback;1}
{//;Set the bomber's bombs scores}
{set;timebomb-scores-bombs-{userid};{math;+;{get;timebomb-scores-bombs-{userid}};1}}
{//;Set the server's bombs scores}
{set;timebomb-scores-bombs-total;{math;+;{get;timebomb-scores-bombs-total};1}}
}
}
;{//;If ~victim is empty}
❌ | Oops! {usermention}, either I couldn't find the specified user in this server, or you cancelled the query! Here are some things you can try:{newline}{//;
}• Mention the user instead of typing out their username.{newline}{//;
}• Type out the full username, including the user tag.{newline}{//;
}• Use a user ID number instead of the username.
}
;{//;If ~canBombUser is false, show this message instead}{set;~timeLeftToBomb;{math;-;60;{get;~currentTimeMinusLastTime}}}❌ | Hey {usermention}, it looks like you've already bombed someone in the past minute. Please wait {if;{get;~timeLeftToBomb};>;1;another {get;~timeLeftToBomb} seconds;just a few more seconds} before trying again.
}
;{//;If command was left empty}
{embed;
{embedbuild;
title:💣 Tick, tick... BOOM!;
description:A recreation of an IRC classic: timebombs! Get your friends and family together for some good 'ol explosive fun!;
fields.name:How to Bomb;
fields.value:Type `b!{commandname} <username>`, replacing `<username>` with the username of the user you want to bomb. You can also mention them, or use their user ID.{newline;2}{//;
}The bombed user will be pinged and presented with three wires—red, white, and blue—in the form of emoji reactions. They need to select one of the three in order to attempt to defuse the bomb. If they pick the right colour, they will be saved{semi} if they pick the wrong one, or don't pick one in time, they will be blown up.;
fields.name:Keeping Score;
fields.value:The command keeps track of all of the bombs you've thrown, and the number of times you defused or were blown up by a bomb. It also keeps track of your highest winning streak.{newline}{//;
}• To view the server scoreboard, type `b!{commandname} -s`{newline}{//;
}• To view a user's scores, type `b!{commandname} -s <username>`;
fields.name:Need help?;
fields.value:Type `b!{commandname} -h` to view additional documentation for the command. You can also find more documentation on [GitHub](https://github.com/CzarHey/discord-timebomb "github.com/CzarHey/discord-timebomb").{newline;2}{//;
}If you have any questions, or if you found a bug with the command, join the [blargbot support server](https://discord.gg/015GVxZxI8rtlJgXF "discord{zws}.gg/015GVxZxI8rtlJgXF") and find me, {exec;person;249223024962830338}, there. I'll do my best to help you out.;
color:e09040;
footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license • Version {get;~version}
}
}
}{//;End blank input check}
;{//;If not being run as a CC, will output this instead}
❌ | This command is being used in the Public Tags system, and will not work properly. Please make sure you import this command into a server, either by typing `b!cc import {commandname}`, or by manually copying the code using the [BBTag Editor](https://blargbot.xyz/tags/editor "blargbot.xyz/tags/editor").
}{//;End CC check}
{func.debug}