Guest User

Timebomb (tag) v1.4

a guest
Sep 10th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.19 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.4T dated September 10, 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}-{args;0};}
  25. {output;βœ… | Done, {usermention}! The variables for {exec;person;{args;0}} have been reset.};
  26. {output;❌ | Sorry {usermention}, but you don't have permission to do this!}
  27. }
  28. }
  29.  
  30. {//;Help output, generated by flag -h}
  31. {if;{flagset;h};==;true;
  32. {output;
  33. {embed;
  34. {embedbuild;
  35. title:πŸ’£ Timebomb Help;
  36. description:**__Using the command__**{newline;2}{//;
  37. }Type ``b!{commandname} <username / user ID / user mention>`` to bomb the selected user.{newline}{//;
  38. }The bot will respond by mentioning the target user and adding three emoji reactions to the message: a red, white, and blue circle.{newline}{//;
  39. }The bot will then DM you the correct wire colour, just for fun!{newline;2}{//;
  40. }**__Cutting the wire__**{newline;2}{//;
  41. }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}{//;
  42. }**__Outcome__**{newline;2}{//;
  43. }β€’ If the target user cuts the correct wire, they will be saved. If not, the bomb will go off.{newline}{//;
  44. }β€’ If the target user doesn't respond within one minute, the bomb will go off.{newline}{//;
  45. }β€’ If the bomb goes off, the target user will be informed of the correct wire colour that they should've picked.{newline;2}{//;
  46. }**__Can't bomb someone?__**{newline;2}{//;
  47. }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}{//;
  48. }**__Flags__**{newline;2}{//;
  49. }``-d`` – Enables debug output. For debugging purposes only.{newline}{//;
  50. }``-h`` – Displays this help output.{newline}{//;
  51. }``-q`` – Quiet mode. Silences the DM the bot sends to the bombing user.{newline}{//;
  52. }``-r`` – Resets the variables for the command. For debugging purposes only.{newline;2}{//;
  53. }**__Found a bug?__**{newline;2}{//;
  54. }Join the [blargbot support server](https://discord.gg/015GVxZxI8rtlJgXF) and find me, {exec;person;249223024962830338}, there. I'll do my best to help you out.;
  55. color:e09040;
  56. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license β€’ Version 1.4T
  57. }
  58. }
  59. }
  60. }
  61.  
  62. {//;Check to see if the user left the command blank}
  63. {if;>;{argslength};0;
  64.  
  65. {//;Check to see if the user has ever bombed anyone in the past}
  66. {if;{length;{get;lastBombTime-{guildid}-{userid}}};>;0;
  67. {//;If true, take the current Unix time and subtract it from the last bomb time}
  68. {set;~currentTimeMinusLastTime;
  69. {math;-;{time;X};{get;lastBombTime-{guildid}-{userid}}}
  70. }
  71. {//;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.}
  72. {if;{get;~currentTimeMinusLastTime};>;60;{set;~canBombUser;true};{set;~canBombUser;false}};
  73.  
  74. {//;If user has never bombed anyone on this server, ever, allow them to bomb}
  75. {set;~canBombUser;true}
  76. }
  77.  
  78. {//;Check to see if the bomber has bombed someone in the past 60 seconds based on the check above}
  79. {if;{get;~canBombUser};==;true;
  80.  
  81. {//;Get the victim's user ID}
  82. {set;~victim;{userid;{args};quiet}}
  83. {//;Check to see if the victim is in the server or if their user ID is valid}
  84. {if;{get;~victim};==;;
  85. ❌ | 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.;
  86.  
  87. {//;If user tried to blow up blargbot}
  88. {if;{get;~victim};==;134133271750639616;❌ | You thought you could trick me into bombing myself, {usermention}?!;
  89. {//;If user tried to blow themselves up}
  90. {if;{get;~victim};==;{userid};❌ | Please, {usermention}! Pick a friend if you have to!;
  91. {//;If user tried to blow up a bot}
  92. {if;{userisbot;{get;~victim}};==;true;❌ | I'm not bombing one of my own kin, {usermention}! Pick a *human* to blow up.;
  93.  
  94. {//;Else, let the show continue}
  95.  
  96. {//;Set the Unix timestamp of the bombing message}
  97. {set;!lastBombTime-{guildid}-{userid};
  98. {messagetime;
  99. {messageid};X
  100. }
  101. }
  102.  
  103. {//;Set the wire color}
  104. {set;~wireColor;{randchoose; πŸ”΄ ; βšͺ ; πŸ”΅ }}
  105.  
  106. {//;Get the text version of the color}
  107. {set;~wireColorText;
  108. {switch;{get;~wireColor};
  109. πŸ”΄ ; red;
  110. βšͺ ; white;
  111. πŸ”΅ ; blue;
  112. ❌ **FATAL ERROR**: No wire color was set!!!
  113. }
  114. }
  115.  
  116. {//;Generate output message text}
  117. {void;{set;~msgemoji;πŸ’£} | {set;~msgtext;{randchoose;
  118. ね, {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!;
  119. 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!;
  120. 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.;
  121. *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!;
  122. 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.
  123. }}}
  124.  
  125. {//;Sends the first message to the channel the command was used in}
  126. {set;~msgid;{send;{channelid};{get;~msgemoji} | {get;~msgtext}}}
  127.  
  128. {//; Add the corresponding reactions to the message}
  129. {reactadd;{get;~msgid}; πŸ”΄ ; βšͺ ; πŸ”΅ }
  130.  
  131. {//;DMs the initiating user the colour of the correct wire, unless they set flag -q}
  132. {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.}}
  133.  
  134. {//; Wait until user reacts one of the emojis provided}
  135. {void;
  136. {waitreaction;{get;~msgid};{userid;{get;~victim}};πŸ”΄ βšͺ πŸ”΅ ;{set;~reaction;{reaction}}true;60
  137. }
  138. }
  139.  
  140. {//;Process the reaction. If they picked the right colour, return success. If not, return fail. If they timed out, return timeout.}
  141. {void;
  142. {set;~result;
  143. {switch;{get;~reaction};
  144. πŸ”΄ ; {//;User reacted red}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  145. βšͺ ; {//;User reacted white}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  146. πŸ”΅ ; {//;User reacted blue}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  147. {//;User timed out}timeout
  148. }
  149. }
  150. }
  151.  
  152. {//;Display either a success, fail, or timeout message}
  153. {switch;{get;~result};
  154. success;
  155. {//;Modify variables}
  156. {set;~msgemoji;βœ…}
  157. {//;Edit the message}
  158. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-successmsg}};
  159. fail;
  160. {//;Modify variables}
  161. {set;~msgemoji;πŸ’₯}
  162. {//;Edit the message}
  163. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-failmsg} (You should have picked the {get;~wireColorText} wire)};
  164. timeout;
  165. {//;Modify variables}
  166. {set;~msgemoji;πŸ’₯}
  167. {//;Edit the message}
  168. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{exec;bomb-timeoutmsg} (You should have picked the {get;~wireColorText} wire)};
  169. ❌ | Uh oh, something went wrong! Please report this error to {exec;person;249223024962830338}!
  170. }
  171.  
  172. }{//;End robot genocide check}
  173. }{//;End suicide check}
  174. }{//;End blargy immunity check}
  175. }{//;End victim user ID check}
  176. ;{//;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.
  177. }{//;End bomb throttling check}
  178.  
  179. {//;If command was left empty}
  180. ;{embed;
  181. {embedbuild;
  182. title:πŸ’£ Tick, tick... BOOM!;
  183. 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}{//;
  184. }**Found a bug?**{newline;2}{//;
  185. }Join the [blargbot support server](https://discord.gg/015GVxZxI8rtlJgXF) and find me, {exec;person;249223024962830338}, there. I'll do my best to help you out.;
  186. color:e09040;
  187. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license β€’ Version 1.4T
  188. }
  189. }
  190. }{//;End empty command check}
  191.  
  192. ;{//;If not being run as a CC, will output this instead}
  193. {embed;
  194. {embedbuild;
  195. title:πŸ’£ Tick, tick... BOOM!;
  196. 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}{//;
  197. }β€’ User A uses the "timebomb" command on User B.{newline}{//;
  198. }β€’ 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}{//;
  199. }β€’ User B needs to respond back with the correct colour in order to defuse the bomb.{newline}{//;
  200. }β€’ If User B guesses the right colour, they are saved.{newline}{//;
  201. }β€’ 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}{//;
  202. }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}{//;
  203. }**Cool! How do I add this to my server?**{newline;2}{//;
  204. }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}{//;
  205. }β€’ You are either the Owner of, or have Admin permissions on, the server you want to add it to.{newline}{//;
  206. }β€’ blargbot has permissions to Read and Send Messages, Add Emoji Reactions, and Read Message History.{newline;2}{//;
  207. }You can then import the command in two ways:{newline;2}{//;
  208. }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}{//;
  209. }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).{newline;2}{//;
  210. }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!;
  211. color:e09040;
  212. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license β€’ Version 1.4T
  213. }
  214. }
  215. }{//;End CC check}
  216. {//;DEBUG MODE - set with flag -d}
  217. {if;{flagset;d};==;true;**__Debugging information__**:
  218.  
  219. **Variables**
  220. ~currentTimeMinusLastTime: {get;~currentTimeMinusLastTime}
  221. lastBombTime-{guildid}-{userid}: {get;lastBombTime-{guildid}-{userid}}
  222. ~canBombUser: {get;~canBombUser}
  223. ~timeLeftToBomb: {get;~timeLeftToBomb}
  224. ~victim: {get;~victim}
  225. ~wireColor: {get;~wireColor}
  226. ~wireColorText: {get;~wireColorText}
  227. ~msgid: {get;~msgid}
  228. ~reaction: {get;~reaction}
  229. ~msgemoji: {get;~msgemoji}
  230. ~result: {get;~result}
  231.  
  232. **Command info**
  233. isstaff: {isstaff}
  234. commandname: {commandname}
  235. messagesender: {messagesender} ({exec;person;{messagesender}})
  236. iscc: {iscc}
  237. }
  238.  
Add Comment
Please, Sign In to add comment