Timebomb command for Discord

The below documentation is outdated. If you would like to import the command into your server, please see the GitHub repository.

I joined Discord in August 2017. Back then I was still mostly an IRC user, and while Discord immediately captivated me with many things reminiscent of the good 'ol IRC era, there was still one thing missing: a bot with a timebomb command.

For those who are unaware, a "timebomb" was a fun IRC bot command that allowed you to "bomb" other users. Here's how it works:
  • User A uses the "timebomb" command on User B.
  • 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.
  • User B needs to respond back with the correct colour in order to defuse the bomb.
  • If User B guesses the right colour, they are saved.
  • 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. Depending on the IRC bot, and if the IRC bot is opped, they will be kicked from the channel.
I've always wanted a bot with a command like that on Discord. Unfortunately, I couldn't find one that had the command. I didn't have the expertise nor the money to create and host my own bot. But I did have blargbot.

blargbot is a Discord bot that features quite a number of neat features that other bots have: auto-moderation, logging, and silly image commands. But one of its strongest features is its very sophisticated custom commands feature that allows users to create their own custom commands for the bot. It comes with a library of tags, known as BBTag, that acts as a kind of programming language for custom commands. At first glance, the complexity deters most novice server managers, who scamper off to find bots like MEE6 with simpler functionality. But with some time and patience, and getting to know how the system works, it is indeed quite amazing to be able to create your own custom commands that are more sophisticated than what other Discord bots offer (looking at you, MEE6).

Anyways, back to the chase. After some tinkering around this morning, I managed to create a working "timebomb" command for blargbot! One IRC memory ported over to Discord! Here's how it works:
  • User A uses the "bomb" command on User B.
  • blargbot will ping User B and give User B the option to cut either the red, blue, or white wire to try to defuse the bomb. blargbot will add three emoji reactions—a red, blue, and white circle—to her message.
  • User B needs to click on the appropriate emoji reaction to cut the wire and try to defuse the bomb.
  • If User B guesses the right colour, they are saved.
  • If User B guesses the wrong colour, or if they don't respond within one minute, the bomb will go off.
  • Because Discord is different from IRC, the user is not kicked. What's funny on IRC is not always funny on Discord.

Adding the command to your server

Firstly, you must be either the Owner of, or have the Administrator permission on, the server you want to add it to. Then, if blargbot isn't already in your server, you will need to invite the bot. The invite link can be found on the bot's website. The bot at the very least requires the ability to read and send messages, to add reactions, and to read the message history.

Then, you can add the command either by importing it as a public tag, or by manually importing the code.

Importing as a public tag

The easiest way to add the command to your server is to go to any channel the bot is in on your server, and type the following:

b!cc import timebomb

This will import the code directly from the bot's public tags system and make it available for use on your server. No additional setup is required. You will be able to use the command on the server by typing b!timebomb.

This method is good if you just want the command and don't care about customizability. You'll get any updates made to the command immediately, without any intervention on your part.

Importing manually

This method takes longer, but will allow you to customize the command to your heart's content (or your server's needs) by letting you change the code for yourself. It is also good if you don't like updates being forced down your throat without your consent, and want to manually approve changes.
  1. Go to the bot's website and click on "Tag IDE" in the sidebar on the left. This will access the blargbot BBTag Editor, which will allow you to more easily add custom commands to your server. You will need to authorize access to your Discord account (it needs to know which servers you're in).
  2. Click on the drop-down menu underneath "Destination" (if it closes, just click on it again), and then select the server you want to add it to from the drop-down.
  3. In "Tag Name", type "bomb".
  4. Navigate to https://pastebin.com/vDL6jstF.
  5. Copy the text in the Pastebin and paste it into the BBTag Editor.
  6. In the BBTag Editor, click on "Save".
  7. In "Tag Name", type "bomb-successmsg".
  8. Navigate to https://pastebin.com/8LNh7ut1.
  9. Copy the text in the Pastebin and paste it into the BBTag Editor.
  10. In the BBTag Editor, click on "Save".
  11. In "Tag Name", type "bomb-failmsg".
  12. Navigate to https://pastebin.com/wTvzSsb4.
  13. Copy the text in the Pastebin and paste it into the BBTag Editor.
  14. In the BBTag Editor, click on "Save".
  15. In "Tag Name", type "bomb-timeoutmsg".
  16. Navigate to https://pastebin.com/Vd3bhgNT.
  17. Copy the text in the Pastebin and paste it into the BBTag Editor.
  18. Test the command in your server! Find a friend to test it with or use an alt account and make sure everything's working smoothly. Your users will be able to use the command by typing b!bomb.
Below is an example of the command in action.

Customizing

If you imported the command manually, you can use the BBTag Editor linked above to edit the command. Just open up the editor, type "bomb" into the "Tag Name" field, select your server from the "Destination" drop-down menu, and select "Load". You can then edit the text for the command from there. When you want to save your changes, just click "Save".

To customize the text for the "success" messages that appear when a user successfully guesses the right colour, edit the command "bomb-successmsg". Likewise, to customize the text for the "fail" messages that appear when a user guesses the wrong colour, edit the command "bomb-failmsg". To customize the text for the "timeout" messages that appear when a user fails to pick a wire in time, edit the command "bomb-timeoutmsg". They're stored in different commands in order to avoid duplication in the main command, and to make it easier to update them. All other text is stored in the main "bomb" command.

You probably don't want the "bomb-successmsg", "bomb-failmsg", and "bomb-timeoutmsg" commands to appear in the custom commands list and be usable by everyone in your server, since they're meant to be auxiliary commands. You can hide those commands by typing b!cc hide bomb-successmsg, b!cc hide bomb-failmsg, and  b!cc hide bomb-timeoutmsg. Hidden commands won't appear when you type b!help, but they will appear when you type b!cc list.

Known issues/caveats

I hope there are no bugs with this command. From my testing it should work just fine on its own. I have noticed two issues:
  • If the bombed user clicks on an emoji reaction while the bot is still setting the reactions up, that input will be ignored. They need to either remove the reaction and add it again, or select another one.
  • If the bot is lagged while waiting for user input, and the user clicks on all of the emoji reactions, the bomb will be defused even if they had picked the wrong wire first.
The following caveats are implemented into the code of the command, and you can remove them if you'd like (if you know what you're doing, that is!):
  • You cannot bomb yourself.
  • You cannot bomb blargbot.
  • You cannot bomb other bots.
  • When you bomb someone, the bot will always mention them, so they'll get a notification. Therefore, don't bomb people too many times in a row, or they'll wake up to seeing a hundred notifications from Discord (and will most likely hate you for it).
  • There is a one minute cooldown between bombings.
The following caveats are either due to restrictions in Discord or blargbot:
  • The command cannot be used in the public tags system (accessible via b!tag, the public tags system allows people to create custom commands that can be used in any server the bot is in), due to needed functionality being disabled in the public tags system.
  • You must use the BBTag Editor to set up the main "bomb" command. The code for the command is greater than 2,000 characters, meaning that it cannot be entered through Discord.
Give credit where credit is due, but otherwise you're totally welcome to take the code and do whatever you want with it. Study it, make your own commands, whatever.

Happy bombing!

Version history

  • Version 1.0 (released May 8, 2020)
    • Initial release
  • Version 1.1 (released June 21, 2020) (CC)
    • Switch "wireColor" and "wireColorText" to use temporary variables for faster performance.
    • Adjust bomb-failmsg mention positioning for consistency.
    • Add version and author information in command code.
  • Version 1.1T (released July 26, 2020)
    • Initial release of the public tags import version.
  • Version 1.2 (released July 30, 2020) (tag; CC)
    • Restructure code for easier readability.
    • Update default message (used when no parameters are given) to use Discord embed.
    • Display version number in default message.
    • (Public tags version only) Default message displays creator name and CC BY-SA license.
    • Bot DMs the correct wire colour to the initiating user.
  • Version 1.3 (released August 7, 2020) (tag; CC)
    • Add built-in cooldown timer that prevents users from bombing again if they had already successfully bombed someone less than a minute ago.
    • Default message displays creator name and CC BY-SA license on both versions.
    • Add debug output flag for debugging purposes.
    • Add reset variables flag for debugging purposes.
    • Add experimental help flag to display help output.
    • Add information on where to report bugs for the command.
  • Version 1.4 (released September 10, 2020) (tagCC)
    • Command now only sends one message. When the user picks a wire colour (or fails to select one in time), the bot will now edit the first message sent, rather than sending a second message.
    • Update success, fail, and timeout messages to reflect this new change.
    • Timeout messages broken off into separate auxiliary command.
    • Built-in cooldown timer uses local variables to address an exploit that allowed non-admins to reset their cooldown timer.
    • Update "user not found" message to include user mentions.
    • currentTimeMinusLastTime temporary variable no longer uses redundant {userid} tag.
    • Fix hidden {waitreaction} error (was only visible in debug output).
  • Version 1.5 (released September 26, 2020) (tag; CC)
    • Add scores feature that keeps track of user bombs, successful and unsuccessful defusals, timeouts, and win streaks.
    • Addressed an issue with the cooldown timer reset command that resulted in the rest of the command running erroneously when used.
    • Embed links show destination URL upon mouseover.
    • Remove redundant {guildid} subtag from local CC version.

Comments

Popular posts from this blog

Experiments with Vibrance HDR

"Meet the man behind a third of what's on Wikipedia" CBS article is wrong