Guest User

Bomb command (v1.5)

a guest
Sep 26th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.35 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.5 dated September 26, 2020
  9. }
  10.  
  11. {//;Reset lastBombTime variable if flag -r is set. For debugging purposes only.}
  12. {if;{flagset;r};==;true;
  13. {//;k6ka can reset variables regardless of permissions}
  14. {if;{userid};==;249223024962830338;{set;~canResetVariables;true};
  15. {//;Allow server staff to reset variables}
  16. {if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
  17. }
  18.  
  19. {if;{get;~canResetVariables};==;true;
  20. {//;Reset variables}
  21. {set;lastBombTime-{flag;r};}
  22. {output;✅ | Done, {usermention}! The cooldown timer for {exec;person;{flag;r}} has been reset.};
  23. {output;❌ | Sorry {usermention}, but you don't have permission to do this!}
  24. }
  25. {return}{//;Stop the rest of the command from running}
  26. }
  27. {//;Reset scores variables if flag -t is set. For debugging purposes only.}
  28. {if;{flagset;t};==;true;
  29. {//;k6ka can reset variables regardless of permissions}
  30. {if;{userid};==;249223024962830338;{set;~canResetVariables;true};
  31. {//;Allow server staff to reset scores}
  32. {if;{isstaff;{userid}};==;true;{set;~canResetVariables;true};{set;~canResetVariables;false}}
  33. }
  34.  
  35. {if;{get;~canResetVariables};==;true;
  36. {//;Reset scores}
  37. {set;scores-success-{flag;t};}
  38. {set;scores-fail-{flag;t};}
  39. {set;scores-timeout-{flag;t};}
  40. {set;scores-bombs-{flag;t};}
  41. {set;scores-streak-{flag;t};}
  42. {output;✅ | Done, {usermention}! The scores for {exec;person;{flag;t}} have been reset.};
  43. {output;❌ | Sorry {usermention}, but you don't have permission to do this!}
  44. }
  45. {return}{//;Stop the rest of the command from running}
  46. }
  47.  
  48. {//;Scores output, generated by flag -s}
  49. {if;{flagset;s};==;true;
  50. {//;Check user input.}
  51. {set;~scoresUser;{userid;{flag;s};quiet}}
  52. {//;If user specified isn't found, default to current user.}
  53. {if;{get;~scoresUser};==;;{set;~scoresUser;{userid}};{//;Don't change ~scoresUser; keep it the same}}
  54.  
  55. {output;
  56. {embed;
  57. {embedbuild;
  58. title:🏆 Timebomb Scores for {exec;person;{get;~scoresUser}};
  59. description:{//;
  60. }✅ Number of successful defusals: {if;{get;scores-success-{get;~scoresUser}};==;{//;Empty};0;{get;scores-success-{get;~scoresUser}}}{newline}{//;
  61. }đŸ’Ĩ Number of unsuccessful defusals: {if;{get;scores-fail-{get;~scoresUser}};==;{//;Empty};0;{get;scores-fail-{get;~scoresUser}}}{newline}{//;
  62. }⏲ī¸ Number of timeouts: {if;{get;scores-timeout-{get;~scoresUser}};==;{//;Empty};0;{get;scores-timeout-{get;~scoresUser}}}{newline}{//;
  63. }đŸ’Ŗ Number of bombs thrown: {if;{get;scores-bombs-{get;~scoresUser}};==;{//;Empty};0;{get;scores-bombs-{get;~scoresUser}}}{newline}{//;
  64. }🌩ī¸ Current winning streak: {if;{get;scores-streak-{get;~scoresUser}};==;{//;Empty};0;{get;scores-streak-{get;~scoresUser}}};
  65. color:{if;{exec;usercolor;{get;~scoresUser}};==;;F7F8F9;{exec;usercolor;{get;~scoresUser}}};
  66. footer.text:Initiated by {exec;person;{userid}}
  67. }
  68. }
  69. }
  70. {return}{//;Stop the rest of the command from running}
  71. }
  72.  
  73. {//;Help output, generated by flag -h}
  74. {if;{flagset;h};==;true;
  75. {output;
  76. {embed;
  77. {embedbuild;
  78. title:đŸ’Ŗ Timebomb Help;
  79. description:**__Using the command__**{newline;2}{//;
  80. }Type ``b!{commandname} <username / user ID / user mention>`` to bomb the selected user.{newline}{//;
  81. }The bot will respond by mentioning the target user and adding three emoji reactions to the message: a red, white, and blue circle.{newline}{//;
  82. }The bot will then DM you the correct wire colour, just for fun!{newline;2}{//;
  83. }**__Cutting the wire__**{newline;2}{//;
  84. }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}{//;
  85. }**__Outcome__**{newline;2}{//;
  86. }â€ĸ If the target user cuts the correct wire, they will be saved. If not, the bomb will go off.{newline}{//;
  87. }â€ĸ If the target user doesn't respond within one minute, the bomb will go off.{newline}{//;
  88. }â€ĸ If the bomb goes off, the target user will be informed of the correct wire colour that they should've picked.{newline;2}{//;
  89. }**__Can't bomb someone?__**{newline;2}{//;
  90. }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}{//;
  91. }**__Flags__**{newline;2}{//;
  92. }``-d`` – Enables debug output. For debugging purposes only.{newline}{//;
  93. }``-h`` – Displays this help output.{newline}{//;
  94. }``-q`` – Quiet mode. Silences the DM the bot sends to the bombing user.{newline}{//;
  95. }``-r`` – Resets the variables for the command. For debugging purposes only.{newline;2}{//;
  96. }**__Found a bug?__**{newline;2}{//;
  97. }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.;
  98. color:e09040;
  99. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license â€ĸ Version 1.5
  100. }
  101. }
  102. }
  103. {return}{//;Stop the rest of the command from running}
  104. }
  105.  
  106. {//;Check to see if the user left the command blank}
  107. {if;>;{argslength};0;
  108.  
  109. {//;Check to see if the user has ever bombed anyone in the past}
  110. {if;{length;{get;lastBombTime-{userid}}};>;0;
  111. {//;If true, take the current Unix time and subtract it from the last bomb time}
  112. {set;~currentTimeMinusLastTime;
  113. {math;-;{time;X};{get;lastBombTime-{userid}}}
  114. }
  115. {//;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.}
  116. {if;{get;~currentTimeMinusLastTime};>;60;{set;~canBombUser;true};{set;~canBombUser;false}};
  117.  
  118. {//;If user has never bombed anyone on this server, ever, allow them to bomb}
  119. {set;~canBombUser;true}
  120. }
  121.  
  122. {//;Check to see if the bomber has bombed someone in the past 60 seconds based on the check above}
  123. {if;{get;~canBombUser};==;true;
  124.  
  125. {//;Get the victim's user ID}
  126. {set;~victim;{userid;{args};quiet}}
  127. {//;Check to see if the victim is in the server or if their user ID is valid}
  128. {if;{get;~victim};==;;
  129. ❌ | 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.;
  130.  
  131. {//;If user tried to blow up blargbot}
  132. {if;{get;~victim};==;134133271750639616;❌ | You thought you could trick me into bombing myself, {usermention}?!;
  133. {//;If user tried to blow themselves up}
  134. {if;{get;~victim};==;{userid};❌ | Please, {usermention}! Pick a friend if you have to!;
  135. {//;If user tried to blow up a bot}
  136. {if;{userisbot;{get;~victim}};==;true;❌ | I'm not bombing one of my own kin, {usermention}! Pick a *human* to blow up.;
  137.  
  138. {//;Else, let the show continue}
  139.  
  140. {//;Set the Unix timestamp of the bombing message}
  141. {set;!lastBombTime-{userid};
  142. {messagetime;
  143. {messageid};X
  144. }
  145. }
  146.  
  147. {//;Set the wire color}
  148. {set;~wireColor;{randchoose; 🔴 ; âšĒ ; đŸ”ĩ }}
  149.  
  150. {//;Get the text version of the color}
  151. {set;~wireColorText;
  152. {switch;{get;~wireColor};
  153. 🔴 ; red;
  154. âšĒ ; white;
  155. đŸ”ĩ ; blue;
  156. ❌ **FATAL ERROR**: No wire color was set!!!
  157. }
  158. }
  159.  
  160. {//;Generate output message text}
  161. {void;{set;~msgemoji;đŸ’Ŗ} | {set;~msgtext;{randchoose;
  162. ね, {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!;
  163. 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!;
  164. 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.;
  165. *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!;
  166. 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.
  167. }}}
  168.  
  169. {//;Sends the first message to the channel the command was used in}
  170. {set;~msgid;{send;{channelid};{get;~msgemoji} | {get;~msgtext}}}
  171.  
  172. {//; Add the corresponding reactions to the message}
  173. {reactadd;{get;~msgid}; 🔴 ; âšĒ ; đŸ”ĩ }
  174.  
  175. {//;DMs the initiating user the colour of the correct wire, unless they set flag -q}
  176. {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.}}
  177.  
  178. {//; Wait until user reacts one of the emojis provided}
  179. {void;
  180. {waitreaction;{get;~msgid};{userid;{get;~victim}};🔴 âšĒ đŸ”ĩ ;{set;~reaction;{reaction}}true;60
  181. }
  182. }
  183.  
  184. {//;Process the reaction. If they picked the right colour, return success. If not, return fail. If they timed out, return timeout.}
  185. {void;
  186. {set;~result;
  187. {switch;{get;~reaction};
  188. 🔴 ; {//;User reacted red}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  189. âšĒ ; {//;User reacted white}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  190. đŸ”ĩ ; {//;User reacted blue}{if;{get;~reaction};contains;{get;~wireColor};success;fail};
  191. {//;User timed out}timeout
  192. }
  193. }
  194. }
  195.  
  196. {//;Display either a success, fail, or timeout message}
  197. {switch;{get;~result};
  198. success;
  199. {//;Modify variables}
  200. {set;~msgemoji;✅}
  201. {//;Edit the message}
  202. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{execcc;bomb-successmsg}};
  203. fail;
  204. {//;Modify variables}
  205. {set;~msgemoji;đŸ’Ĩ}
  206. {//;Edit the message}
  207. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{execcc;bomb-failmsg} (You should have picked the {get;~wireColorText} wire)};
  208. timeout;
  209. {//;Modify variables}
  210. {set;~msgemoji;đŸ’Ĩ}
  211. {//;Edit the message}
  212. {edit;{get;~msgid};{get;~msgemoji} | {get;~msgtext}{newline;2}{execcc;bomb-timeoutmsg} (You should have picked the {get;~wireColorText} wire)};
  213. ❌ | Uh oh, something went wrong! Please report this error to {exec;person;249223024962830338}!
  214. }
  215.  
  216. {//;Set scores}
  217. {void;
  218. {//;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.}
  219. {fallback;1}
  220. {//;Set victim's scores}
  221. {switch;{get;~result};
  222. success;{//;If success, add to their success score}
  223. {set;scores-success-{get;~victim};{math;+;{get;scores-success-{get;~victim}};1}}
  224. {//;Add to streak score}
  225. {set;scores-streak-{get;~victim};{math;+;{get;scores-streak-{get;~victim}};1}};
  226. fail;{//;If fail, add to their fail score}
  227. {set;scores-fail-{get;~victim};{math;+;{get;scores-fail-{get;~victim}};1}}
  228. {//;Reset streak score}
  229. {set;scores-streak-{get;~victim};};
  230. timeout;{//;If timeout, add to their timeout score}
  231. {set;scores-timeout-{get;~victim};{math;+;{get;scores-timeout-{get;~victim}};1}}
  232. {//;Reset streak score}
  233. {set;scores-streak-{get;~victim};}
  234. }
  235. {//;For bomber, set bomb count}
  236. {set;scores-bombs-{userid};{math;+;{get;scores-bombs-{userid}};1}}
  237. }
  238.  
  239. }{//;End robot genocide check}
  240. }{//;End suicide check}
  241. }{//;End blargy immunity check}
  242. }{//;End victim user ID check}
  243. ;{//;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.
  244. }{//;End bomb throttling check}
  245.  
  246. {//;If command was left empty}
  247. ;{embed;
  248. {embedbuild;
  249. title:đŸ’Ŗ Tick, tick... BOOM!;
  250. 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}{//;
  251. }**Found a bug?**{newline;2}{//;
  252. }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.;
  253. color:e09040;
  254. footer.text:Command created by {exec;person;249223024962830338} and is licensed under a CC BY-SA license â€ĸ Version 1.5
  255. }
  256. }
  257. }{//;End empty command check}
  258.  
  259. {//;DEBUG MODE - set with flag -d}
  260. {if;{flagset;d};==;true;**__Debugging information__**:
  261.  
  262. **Variables**
  263. ~currentTimeMinusLastTime: {get;~currentTimeMinusLastTime}
  264. lastBombTime-{userid}: {get;lastBombTime-{userid}}
  265. ~canBombUser: {get;~canBombUser}
  266. ~timeLeftToBomb: {get;~timeLeftToBomb}
  267. ~victim: {get;~victim}
  268. ~wireColor: {get;~wireColor}
  269. ~wireColorText: {get;~wireColorText}
  270. ~msgid: {get;~msgid}
  271. ~reaction: {get;~reaction}
  272. ~msgemoji: {get;~msgemoji}
  273. ~result: {get;~result}
  274. scores-success-{get;~victim}: {get;scores-success-{get;~victim}}
  275. scores-fail-{get;~victim}: {get;scores-fail-{get;~victim}}
  276. scores-timeout-{get;~victim}: {get;scores-timeout-{get;~victim}}
  277. scores-bombs-{get;~victim}: {get;scores-bombs-{get;~victim}}
  278. scores-streak-{get;~victim}: {get;scores-streak-{get;~victim}}
  279.  
  280. **Command info**
  281. isstaff: {isstaff}
  282. commandname: {commandname}
  283. messagesender: {messagesender} ({exec;person;{messagesender}})
  284. iscc: {iscc}
  285. }
  286.  
Add Comment
Please, Sign In to add comment