Guest User

Timebomb command (tag) v1.5

a guest
Sep 26th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.40 KB | None | 0 0
  1. {//; BLARGBOT TIMEBOMB COMMAND
  2.  
  3. * Created by k6ka#1014
  4. * Code is released under a Creative Commons Attribution-ShareAlike license
  5. * Give credit where credit is due!
  6. * See https://k6ka.blogspot.com/2020/05/timebomb-command-for-discord.html for instructions
  7.  
  8. Version 1.5T dated September 26, 2020
  9. }
  10.  
  11. {//;Check to see if this is being run as a custom command in a server}
  12. {if;{iscc};{//;If true, then run the rest of the command}
  13.  
  14. {//;Reset lastBombTime variable if flag -r is set. For debugging purposes only.}
  15. {if;{flagset;r};==;true;
  16. {//;k6ka can reset variables regardless of permissions}
  17. {if;{userid};==;249223024962830338;{set;~canResetVariables;true};
  18. {//;Allow server staff to reset variables}
  19. {if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
  20. }
  21.  
  22. {if;{get;~canResetVariables};==;true;
  23. {//;Reset variables}
  24. {set;lastBombTime-{guildid}-{flag;r};}
  25. {output;✅ | Done, {usermention}! The cooldown timer for {exec;person;{flag;r}} has been reset.};
  26. {output;❌ | Sorry {usermention}, but you don't have permission to do this!}
  27. }
  28. {return}{//;Stop the rest of the command from running}
  29. }
  30. {//;Reset scores variables if flag -t is set. For debugging purposes only.}
  31. {if;{flagset;t};==;true;
  32. {//;k6ka can reset variables regardless of permissions}
  33. {if;{userid};==;249223024962830338;{set;~canResetVariables;true};
  34. {//;Allow server staff to reset scores}
  35. {if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
  36. }
  37.  
  38. {if;{get;~canResetVariables};==;true;
  39. {//;Reset scores}
  40. {set;scores-success-{guildid}-{flag;t};}
  41. {set;scores-fail-{guildid}-{flag;t};}
  42. {set;scores-timeout-{guildid}-{flag;t};}
  43. {set;scores-bombs-{guildid}-{flag;t};}
  44. {set;scores-streak-{guildid}-{flag;t};}
  45. {output;✅ | Done, {usermention}! The scores for {exec;person;{flag;t}} have been reset.};
  46. {output;❌ | Sorry {usermention}, but you don't have permission to do this!}
  47. }
  48. {return}{//;Stop the rest of the command from running}
  49. }
  50.  
  51. {//;Scores output, generated by flag -s}
  52. {if;{flagset;s};==;true;
  53. {//;Check user input.}
  54. {set;~scoresUser;{userid;{flag;s};quiet}}
  55. {//;If user specified isn't found, default to current user.}
  56. {if;{get;~scoresUser};==;;{set;~scoresUser;{userid}};{//;Don't change ~scoresUser; keep it the same}}
  57.  
  58. {output;
  59. {embed;
  60. {embedbuild;
  61. title:🏆 Timebomb Scores for {exec;person;{get;~scoresUser}};
  62. description:{//;
  63. }✅ Number of successful defusals: {if;{get;scores-success-{guildid}-{get;~scoresUser}};==;{//;Empty};0;{get;scores-success-{guildid}-{get;~scoresUser}}}{newline}{//;
  64. }đŸ’Ĩ Number of unsuccessful defusals: {if;{get;scores-fail-{guildid}-{get;~scoresUser}};==;{//;Empty};0;{get;scores-fail-{guildid}-{get;~scoresUser}}}{newline}{//;
  65. }⏲ī¸ Number of timeouts: {if;{get;scores-timeout-{guildid}-{get;~scoresUser}};==;{//;Empty};0;{get;scores-timeout-{guildid}-{get;~scoresUser}}}{newline}{//;
  66. }đŸ’Ŗ Number of bombs thrown: {if;{get;scores-bombs-{guildid}-{get;~scoresUser}};==;{//;Empty};0;{get;scores-bombs-{guildid}-{get;~scoresUser}}}{newline}{//;
  67. }🌩ī¸ Current winning streak: {if;{get;scores-streak-{guildid}-{get;~scoresUser}};==;{//;Empty};0;{get;scores-streak-{guildid}-{get;~scoresUser}}};
  68. color:{if;{exec;usercolor;{get;~scoresUser}};==;;F7F8F9;{exec;usercolor;{get;~scoresUser}}};
  69. footer.text:Initiated by {exec;person;{userid}}
  70. }
  71. }
  72. }
  73. {return}{//;Stop the rest of the command from running}
  74. }
  75.  
  76. {//;Help output, generated by flag -h}
  77. {if;{flagset;h};==;true;
  78. {output;
  79. {embed;
  80. {embedbuild;
  81. title:đŸ’Ŗ Timebomb Help;
  82. description:**__Using the command__**{newline;2}{//;
  83. }Type ``b!{commandname} <username / user ID / user mention>`` to bomb the selected user.{newline}{//;
  84. }The bot will respond by mentioning the target user and adding three emoji reactions to the message: a red, white, and blue circle.{newline}{//;
  85. }The bot will then DM you the correct wire colour, just for fun!{newline;2}{//;
  86. }**__Cutting the wire__**{newline;2}{//;
  87. }Click on one of the coloured emoji reactions the bot presents to you to cut the wire. Only the bombed user can cut the wire{semi} other users cannot cut it for them.{newline;2}{//;
  88. }**__Outcome__**{newline;2}{//;
  89. }â€ĸ If the target user cuts the correct wire, they will be saved. If not, the bomb will go off.{newline}{//;
  90. }â€ĸ If the target user doesn't respond within one minute, the bomb will go off.{newline}{//;
  91. }â€ĸ If the bomb goes off, the target user will be informed of the correct wire colour that they should've picked.{newline;2}{//;
  92. }**__Can't bomb someone?__**{newline;2}{//;
  93. }You cannot bomb other bots, nor can you bomb yourself. You also cannot bomb if you have already bombed someone within the past minute.{newline;2}{//;
  94. }**__Flags__**{newline;2}{//;
  95. }``-d`` – Enables debug output. For debugging purposes only.{newline}{//;
  96. }``-h`` – Displays this help output.{newline}{//;
  97. }``-q`` – Quiet mode. Silences the DM the bot sends to the bombing user.{newline}{//;
  98. }``-r`` – Resets the variables for the command. For debugging purposes only.{newline;2}{//;
  99. }**__Found a bug?__**{newline;2}{//;
  100. }Join the [blargbot support server](https://discord.gg/015GVxZxI8rtlJgXF "https://discord.gg/015GVxZxI8rtlJgXF") and find me, {exec;person;249223024962830338}, there. I'll do my best to help you out.;
  101. color:e09040;
  102. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license â€ĸ Version 1.5T
  103. }
  104. }
  105. }
  106. {return}{//;Stop the rest of the command from running}
  107. }
  108.  
  109. {//;Check to see if the user left the command blank}
  110. {if;>;{argslength};0;
  111.  
  112. {//;Check to see if the user has ever bombed anyone in the past}
  113. {if;{length;{get;lastBombTime-{guildid}-{userid}}};>;0;
  114. {//;If true, take the current Unix time and subtract it from the last bomb time}
  115. {set;~currentTimeMinusLastTime;
  116. {math;-;{time;X};{get;lastBombTime-{guildid}-{userid}}}
  117. }
  118. {//;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.}
  119. {if;{get;~currentTimeMinusLastTime};>;60;{set;~canBombUser;true};{set;~canBombUser;false}};
  120.  
  121. {//;If user has never bombed anyone on this server, ever, allow them to bomb}
  122. {set;~canBombUser;true}
  123. }
  124.  
  125. {//;Check to see if the bomber has bombed someone in the past 60 seconds based on the check above}
  126. {if;{get;~canBombUser};==;true;
  127.  
  128. {//;Get the victim's user ID}
  129. {set;~victim;{userid;{args};quiet}}
  130. {//;Check to see if the victim is in the server or if their user ID is valid}
  131. {if;{get;~victim};==;;
  132. ❌ | Oops! I couldn't find the specified user in this server, {usermention}. Please specify a valid username or user ID. You can also mention the user directly.;
  133.  
  134. {//;If user tried to blow up blargbot}
  135. {if;{get;~victim};==;134133271750639616;❌ | You thought you could trick me into bombing myself, {usermention}?!;
  136. {//;If user tried to blow themselves up}
  137. {if;{get;~victim};==;{userid};❌ | Please, {usermention}! Pick a friend if you have to!;
  138. {//;If user tried to blow up a bot}
  139. {if;{userisbot;{get;~victim}};==;true;❌ | I'm not bombing one of my own kin, {usermention}! Pick a *human* to blow up.;
  140.  
  141. {//;Else, let the show continue}
  142.  
  143. {//;Set the Unix timestamp of the bombing message}
  144. {set;!lastBombTime-{guildid}-{userid};
  145. {messagetime;
  146. {messageid};X
  147. }
  148. }
  149.  
  150. {//;Set the wire color}
  151. {set;~wireColor;{randchoose; 🔴 ; âšĒ ; đŸ”ĩ }}
  152.  
  153. {//;Get the text version of the color}
  154. {set;~wireColorText;
  155. {switch;{get;~wireColor};
  156. 🔴 ; red;
  157. âšĒ ; white;
  158. đŸ”ĩ ; blue;
  159. ❌ **FATAL ERROR**: No wire color was set!!!
  160. }
  161. }
  162.  
  163. {//;Generate output message text}
  164. {void;{set;~msgemoji;đŸ’Ŗ} | {set;~msgtext;{randchoose;
  165. ね, {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!;
  166. 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!;
  167. 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.;
  168. *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!;
  169. 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.
  170. }}}
  171.  
  172. {//;Sends the first message to the channel the command was used in}
  173. {set;~msgid;{send;{channelid};{get;~msgemoji} | {get;~msgtext}}}
  174.  
  175. {//; Add the corresponding reactions to the message}
  176. {reactadd;{get;~msgid}; 🔴 ; âšĒ ; đŸ”ĩ }
  177.  
  178. {//;DMs the initiating user the colour of the correct wire, unless they set flag -q}
  179. {if;{flagset;q};==;true;{//;Don't send DMs - user has set quiet mode};{dm;{userid};đŸ¤Ģ | Hey, don't tell {usernick;{get;~victim}}, but it's the {get;~wireColorText} wire.}}
  180.  
  181. {//; Wait until user reacts one of the emojis provided}
  182. {void;
  183. {waitreaction;{get;~msgid};{userid;{get;~victim}};🔴 âšĒ đŸ”ĩ ;{set;~reaction;{reaction}}true;60
  184. }
  185. }
  186.  
  187. {//;Process the reaction. If they picked the right colour, return success. If not, return fail. If they timed out, return timeout.}
  188. {void;
  189. {set;~result;
  190. {switch;{get;~reaction};
  191. 🔴 ; {//;User reacted red}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  192. âšĒ ; {//;User reacted white}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  193. đŸ”ĩ ; {//;User reacted blue}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  194. {//;User timed out}timeout
  195. }
  196. }
  197. }
  198.  
  199. {//;Display either a success, fail, or timeout message}
  200. {switch;{get;~result};
  201. success;
  202. {//;Modify variables}
  203. {set;~msgemoji;✅}
  204. {//;Edit the message}
  205. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-successmsg}};
  206. fail;
  207. {//;Modify variables}
  208. {set;~msgemoji;đŸ’Ĩ}
  209. {//;Edit the message}
  210. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-failmsg} (You should have picked the {get;~wireColorText} wire)};
  211. timeout;
  212. {//;Modify variables}
  213. {set;~msgemoji;đŸ’Ĩ}
  214. {//;Edit the message}
  215. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-timeoutmsg} (You should have picked the {get;~wireColorText} wire)};
  216. ❌ | Uh oh, something went wrong! Please report this error to {exec;person;249223024962830338}!
  217. }
  218.  
  219. {//;Set scores}
  220. {void;
  221. {//;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.}
  222. {fallback;1}
  223. {//;Set victim's scores}
  224. {switch;{get;~result};
  225. success;{//;If success, add to their success score}
  226. {set;scores-success-{guildid}-{get;~victim};{math;+;{get;scores-success-{guildid}-{get;~victim}};1}}
  227. {//;Add to streak score}
  228. {set;scores-streak-{guildid}-{get;~victim};{math;+;{get;scores-streak-{guildid}-{get;~victim}};1}};
  229. fail;{//;If fail, add to their fail score}
  230. {set;scores-fail-{guildid}-{get;~victim};{math;+;{get;scores-fail-{guildid}-{get;~victim}};1}}
  231. {//;Reset streak score}
  232. {set;scores-streak-{guildid}-{get;~victim};};
  233. timeout;{//;If timeout, add to their timeout score}
  234. {set;scores-timeout-{guildid}-{get;~victim};{math;+;{get;scores-timeout-{guildid}-{get;~victim}};1}}
  235. {//;Reset streak score}
  236. {set;scores-streak-{guildid}-{get;~victim};}
  237. }
  238. {//;For bomber, set bomb count}
  239. {set;scores-bombs-{guildid}-{userid};{math;+;{get;scores-bombs-{guildid}-{userid}};1}}
  240. }
  241.  
  242. }{//;End robot genocide check}
  243. }{//;End suicide check}
  244. }{//;End blargy immunity check}
  245. }{//;End victim user ID check}
  246. ;{//;If user has bombed someone recently}{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.
  247. }{//;End bomb throttling check}
  248.  
  249. {//;If command was left empty}
  250. ;{embed;
  251. {embedbuild;
  252. title:đŸ’Ŗ Tick, tick... BOOM!;
  253. description:Type ``b!{commandname} <username>`` to throw a bomb at someone! They have one minute to cut the correct wire or they will be blown to smithereens! Mentions will work, as will user IDs.{newline;2}{//;
  254. }**Found a bug?**{newline;2}{//;
  255. }Join the [blargbot support server](https://discord.gg/015GVxZxI8rtlJgXF "https://discord.gg/015GVxZxI8rtlJgXF") and find me, {exec;person;249223024962830338}, there. I'll do my best to help you out.;
  256. color:e09040;
  257. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license â€ĸ Version 1.5T
  258. }
  259. }
  260. }{//;End empty command check}
  261.  
  262. ;{//;If not being run as a CC, will output this instead}
  263. {embed;
  264. {embedbuild;
  265. title:đŸ’Ŗ Tick, tick... BOOM!;
  266. description:Many IRC bots have a "timebomb" fun command that provides endless hours of ensuing fun with other users. It works a little like this:{newline;2}{//;
  267. }â€ĸ User A uses the "timebomb" command on User B.{newline}{//;
  268. }â€ĸ The IRC bot will ping User B and present them with a selection of coloured wires to cut, along with how much time is on the fuse.{newline}{//;
  269. }â€ĸ User B needs to respond back with the correct colour in order to defuse the bomb.{newline}{//;
  270. }â€ĸ If User B guesses the right colour, they are saved.{newline}{//;
  271. }â€ĸ If User B guesses the wrong colour, or if they don't respond by the time the timer runs out, the bomb will go off.{newline;2}{//;
  272. }I couldn't find any equivalent functionality on Discord, so I made my own implementation using blargbot's BBTag language. It works pretty well, and of course, I'm making the code for it open to everyone.{newline;2}{//;
  273. }**Cool! How do I add this to my server?**{newline;2}{//;
  274. }Since this command needs the ``send`` tag, which is disabled on the public tags system, you'll need to import this command into your server as a custom command in order for it to work. Before you begin, double-check the following:{newline;2}{//;
  275. }â€ĸ You are either the Owner of, or have Admin permissions on, the server you want to add it to.{newline}{//;
  276. }â€ĸ blargbot has permissions to Read and Send Messages, Add Emoji Reactions, and Read Message History.{newline;2}{//;
  277. }You can then import the command in two ways:{newline;2}{//;
  278. }1. Import this command to your server by typing ``b!cc import timebomb``. It will be available for use right away, with no additional setup, and you'll get the latest updates to the command automatically.{newline}{//;
  279. }2. Import the command manually, which will give you more control over the command and allow you to customize it to your liking. Instructions can be found on [my blog](https://k6ka.blogspot.com/2020/05/timebomb-command-for-discord.html "https://k6ka.blogspot.com/2020/05/timebomb-command-for-discord.html").{newline;2}{//;
  280. }I highly encourage you to give this a go and invite some of your friends over to play around with it. Relive some classic IRC fun right in the modern comforts of Discord!;
  281. color:e09040;
  282. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license â€ĸ Version 1.5T
  283. }
  284. }
  285. }{//;End CC check}
  286. {//;DEBUG MODE - set with flag -d}
  287. {if;{flagset;d};==;true;**__Debugging information__**:
  288.  
  289. **Variables**
  290. ~currentTimeMinusLastTime: {get;~currentTimeMinusLastTime}
  291. lastBombTime-{guildid}-{userid}: {get;lastBombTime-{guildid}-{userid}}
  292. ~canBombUser: {get;~canBombUser}
  293. ~timeLeftToBomb: {get;~timeLeftToBomb}
  294. ~victim: {get;~victim}
  295. ~wireColor: {get;~wireColor}
  296. ~wireColorText: {get;~wireColorText}
  297. ~msgid: {get;~msgid}
  298. ~reaction: {get;~reaction}
  299. ~msgemoji: {get;~msgemoji}
  300. ~result: {get;~result}
  301. scores-success-{guildid}-{get;~victim}: {get;scores-success-{guildid}-{get;~victim}}
  302. scores-fail-{guildid}-{get;~victim}: {get;scores-fail-{guildid}-{get;~victim}}
  303. scores-timeout-{guildid}-{get;~victim}: {get;scores-timeout-{guildid}-{get;~victim}}
  304. scores-bombs-{guildid}-{get;~victim}: {get;scores-bombs-{guildid}-{get;~victim}}
  305. scores-streak-{guildid}-{get;~victim}: {get;scores-streak-{guildid}-{get;~victim}}
  306.  
  307. **Command info**
  308. isstaff: {isstaff}
  309. commandname: {commandname}
  310. messagesender: {messagesender} ({exec;person;{messagesender}})
  311. iscc: {iscc}
  312. }
  313.  
Add Comment
Please, Sign In to add comment