menu

blargbot is equipped with a system of tags called BBTag, designed to mimic a programming language while still remaining simple. You can use this system as the building-blocks to create your own advanced command system, whether it be through public tags or guild-specific custom commands.

Have a suggestion for a tag? I'm all ears! Drop me a suggestion using b!suggest or come by my guild to talk to me in person.

Editor

There is also an online BBTag IDE (in beta) that you can use to see the contents of your custom command a little bit easier. Feel free to give it a try!

Features

Variables

BBTag features four different types of variables, each with a different scope. These types are distinguished from each other with prefixes.

Arrays

BBTag has array implementation for more complex data stuctures.

Simple Tags

These tags are just simple replaces, and don't take any arguments.

argslength

Return the number of arguments the user provided.

Example Input:
You said {argslength} words.
Example Output:
Input: I am saying things.
Output: You said 4 words.

channelid

Returns the ID of the current channel

Example Input:
This channel's id is {channelid}
Example Output:
This channel's id is 1234567890123456

channelname

Returns the name of the current channel

Example Input:
This channel's name is #{channelname}
Example Output:
This channel's name is #test-channel

channelpos

Returns the position of the current channel

Example Input:
This channel is in position {channelpos}
Example Output:
This channel is in position 1

delete

Deletes the initiating command.

Example Input:
The message that triggered this will be deleted. {delete}
Example Output:
(the message got deleted idk how to do examples for this)

guilddefaultchannelid

Returns the guild's default channel's id

Example Input:
Default channel is {guilddefaultchannelid}
Example Output:
Default channel is 1234567890123455

guilddefaultchannelname

Returns the guild's default channel's name

Example Input:
Default channel is {guilddefaultchannelname}
Example Output:
Default channel is defaultchannel

guildicon

Returns the icon of the current guild

Example Input:
The guild's icon is {guildicon}
Example Output:
The guild's icon is (icon url)

guildid

Returns the id of the current guild

Example Input:
This guild's id is {guildid}
Example Output:
This guild's id is 1234567890123456

guildmembers

Returns the number of members on the current guild

Example Input:
This guild has {guildmembers} members.
Example Output:
This guild has 123 members.

guildname

Returns the name of the current guild

Example Input:
This guild's name is {guildname}
Example Output:
This guild's name is TestGuild

guildownerid

Returns the id of the guild's owner

Example Input:
The owner's id is {guildownerid}
Example Output:
The owner's id is 1234567890123456

lb

Will be replaced by { on execution.

Example Input:
This is a bracket! {lb}
Example Output:
This is a bracket! {

nsfw

Marks the message is being NSFW, and only to be outputted in NSFW channels. A requirement for any tag with NSFW content.

Example Input:
This command is not safe! {nsfw}
Example Output:
This command is not safe!

prefix

Gets the current guild's prefix.

Example Input:
Your prefix is {prefix}
Example Output:
Your prefix is b!

randuser

Returns the id of a random user on the current guild.

Example Input:
{username;{randuser}} is a lovely person! {username;{randuser}} isn't as good.
Example Output:
abalabahaha is a lovely person! stupid cat isn't as good.

rb

Will be replaced by } on execution.

Example Input:
This is a bracket! {rb}
Example Output:
This is a bracket! }

return

Stops execution of the tag and returns what has been parsed.

Example Input:
This will display. {return} This will not.
Example Output:
This will display.

semi

Will be replaced by ; on execution.

Example Input:
This is a semicolon! {semi}
Example Output:
This is a semicolon! ;

Complex

These tags are more powerful.
<> - denotes required arguments
[] - denotes optional arguments
... - denotes one or more arguments

General

General purpose functions.

//

Arguments: Anything

A tag that just gets removed. Useful for documenting your code.

Example Input:
This is a sentence. {//;This is a comment.}
Example Output:
This is a sentence.

abs

Arguments: <number>

Gets the absolute value of a number

Example Input:
{abs;-535}
Example Output:
535

aget

This tag is deprecated. Avoid using it, as it will eventually become unsupported.

Arguments: <name> [index]

Returns a stored variable, or an index in a stored array. Variables are unique per-author.

Example Input:
{aget;testvar}
Example Output:
This is a test var

args

Arguments: [index] [range]

Gets user input. Specifying an index will only get the word at that location, specifying a range will get all the words between index and range. Specify range as n to get all the words from index to the end

Example Input:
Your second word was {args;1}
Example Output:
Input: Hello world!
Output: Your second word was world!

aset

This tag is deprecated. Avoid using it, as it will eventually become unsupported.

Arguments: <name> <value>

Array compatible

Stores a variable. These variables are saved between sessions, and are unique per-author.

Example Input:
{aset;testvar;This is a test var}
Example Output:

base

Arguments: <integer> [origin] <radix>

Converts a Base origin number into radix. Default origin is 10. radix must be between 2 and 36.

Example Input:
{base;255;16}
Example Output:
FF

bool

Arguments: <evaluator> <arg1> <arg2>

Evaluates arg1 and arg2 using the evaluator and returns true or false. Valid evaluators are == != < <= > >= startswith endswithincludes

Example Input:
{bool;<=;5;10}
Example Output:
true

brainfuck

Arguments: <code>

Interprets brainfuck input.

Example Input:
{abs;++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.}
Example Output:
Hello World!

capitalize

Arguments: <text> [lower]

Capitalizes the first letter of text. If lower is specified the rest of the text will be lowercase

Example Input:
{capitalize;hello world!}
Example Output:
Hello world!

ceil

Arguments: <number>

Rounds a number up.

Example Input:
{ceil;1.23}
Example Output:
2

channel

Arguments: <channel> [message]

Sends the output to a specific channel. Only works in custom commands. If a message is specified, it will create a new message in the specified channel instead of rerouting output.

Example Input:
{channel;#channel}Hello!
Example Output:
In #channel: Hello!

choose

Arguments: <choice> <choices...>

Chooses from the given options, where choice is the index of the option selected

Example Input:
I feel like eating {choose;1;cake;pie;pudding} today.
Example Output:
I feel like eating pie today.

decrement

Arguments: <variable name> [amount]

Decreases the value of the specified variable by the specified amount. Defaults to 1

Example Input:
{set;counter;0} {repeat;{decrement;counter},;10}
Example Output:
-1,-2,-3,-4,-5,-6,-7,-8,-9,-10

emoji

Arguments: <text> [amount]

Gets amount (or 5 if amount isn't specified) emojis related to the given text. There's a limit of 10 emojis.

Example Input:
{emoji;I am hungry;5}
Example Output:
🍔 🍕 😩 🍴 😐

exec

Arguments: <code> [user input]

Executes another tag. Useful for modules.

Example Input:
Let me do a tag for you. {exec;f}
Example Output:
Let me do a tag for you. User#1111 has paid their respects. Total respects given: 5

fallback

Arguments: <message>

Should any tag fail to parse, it will be replaced with the fallback message instead of an error

Example Input:
{fallback;This tag failed} {randint}
Example Output:
This tag failed

floor

Arguments: <number>

Rounds a number down.

Example Input:
{floor;1.23}
Example Output:
1

get

Arguments: <name> [index]

Returns a stored variable, or an index in a stored array. Variables are unique per-tag.

Example Input:
{get;testvar}
Example Output:
This is a test var

guildcreatedat

Arguments: [format]

Returns the date the current guild was created, in UTC+0. If a format code is specified, the date is formatted accordingly. Leave blank for default formatting. See the moment documentation for more information.

Example Input:
This guild was created on {guildcreatedat;YYYY/MM/DD HH:mm:ss}
Example Output:
This guild was created on 2016/01/01 01:00:00

hash

Arguments: <text>

Returns the numeric hash of any given text, based on the unicode value of each individual character. This results in seemingly randomly generated numbers that are constant for each specific query.

Example Input:
The hash of brown is {hash;brown}
Example Output:
The hash of brown is 94011702

if

Arguments: <evaluator> <arg1> <arg2> <then> <else>

Evaluates arg1 and arg2 using the evaluator. If it returns true, the tag returns then. Otherwise, it returns else. Valid evaluators are ==!= < <= > >= startswith endswith includes

Example Input:
{if;<=;5;10;5 is less than or equal to 10;5 is greater than 10}
Example Output:
5 is less than or equal to 10

increment

Arguments: <variable name> [amount]

Increases the value of the specified variable by the specified amount. Defaults to 1

Example Input:
{set;counter;0} {repeat;{increment;counter},;10}
Example Output:
1,2,3,4,5,6,7,8,9,10

indexof

Arguments: <text> <searchfor> [start]

Array compatible

Finds the index of searchfor in text, after start. text can either be plain text or an array. If it's not found, returns -1.

Example Input:
The index of 'o' in 'hello world' is {indexof;hello world;o}
Example Output:
The index of 'o' in 'hello world' is 4

inject

Arguments: <code>

Injects code into the tag. For example, doing {inject;{args}} will let any user execute any code. Use with caution.

Example Input:
Random Number: {inject;{lb}randint{semi}1{semi}4{lb}}
Example Output:
Random Number: 3

lang

Arguments: <language>

Specifies the language used to display the raw contents of this tag.

Example Input:
This will be displayed with js! {lang;js}
Example Output:
This will be displayed with js!

length

Arguments: <text>

Array compatible

Gives the amount of characters in text, or the number of elements if it is an array.

Example Input:
What you said is {length;{args}} chars long.
Example Output:
What you said is 5 chars long.

logic

Arguments: <evaluator> <arg1> <arg2>

Accepts 2 boolean values (true or false) and returns the result of a logic operation on them. Valid logic operators are || && XOR !

Example Input:
{logic;&&;true;false}
Example Output:
false

lower

Arguments: <string>

Returns string as lowercase

Example Input:
{lower;THIS WILL BECOME LOWERCASE}
Example Output:
this will become lowercase

math

Arguments: <operator> <operands...>

Returns a number based on the operator and operands. Valid operators are

  • +
  • -
  • *
  • /
  • %
  • ^

Example Input:
2 + 3 + 6 - 2 = {math;-;{math;+;2;3;6};2}
Example Output:
2 + 3 + 6 - 2 = 9

newline

Arguments: [length]

Will be replaced by a specified number of newline characters (\n).

Example Input:
{newline}Hello, world!
Example Output:
Hello, world!

pad

Arguments: <direction> <text> <back>

Pads back to the direction of text

Example Input:
{pad;left;ABC;000000}
Example Output:
000ABC

parsefloat

Arguments: <text>

Returns an floating point number from text. If it wasn't a number, returns NaN

Example Input:
{parsefloat;abcd} {parsefloat;12.34} {parsefloat;1.2cd}
Example Output:
NaN 12.34 1.2

parseint

Arguments: <text>

Returns an integer from text. If it wasn't a number, returns NaN

Example Input:
{parseint;abcd} {parseint;1234} {parseint;12cd}
Example Output:
NaN 1234 12

randchoose

Arguments: <choices...>

Array compatible

Chooses a random choice

Example Input:
I feel like eating {randchoose;cake;pie;pudding} today.
Example Output:
I feel like eating pudding today.

randint

Arguments: [min] <max>

If only max is specified, gets a random number between max and 0. If both arguments are specified, gets a random number between them.

Example Input:
You rolled a {randint;1;6}
Example Output:
You rolled a 5

randstr

Arguments: <chars> <length>

Creates a random string with characters from chars that is length characters long.

Example Input:
{randstr;1234567890;10}
Example Output:
3789327305

regexreplace

Arguments: [toreplace] <regex> <replacewith>

Replaces the regex phrase with replacewith. If toreplace is specified, the tag is replaced with the new toreplace. If not, it replaces the message.

Example Input:
I like {regexreplace;to consume;/o/gi;a} cheese. {regexreplace;/e/gi;n}
Example Output:
I likn ta cansumn chnnsn.

repeat

Arguments: <text> <amount>

Repeats text amount times.

Example Input:
{repeat;e;10}
Example Output:
eeeeeeeeee

replace

Arguments: [toreplace] <phrase> <replacewith>

Replaces the phrase with replacewith. If toreplace is specified, the tag is replaced with the new toreplace. If not, it replaces the message.

Example Input:
I like {replace;to eat;eat;nom} cheese. {replace;cheese;ham}
Example Output:
I like to nom ham

reverse

Arguments: <text>

Array compatible

Reverses the order of text or an array. If {get} or {aget} are used with an array, will modify the original array.

Example Input:
{sort;text}
Example Output:
txet

round

Arguments: <number>

Rounds a number up or down.

Example Input:
{round;1.23}
Example Output:
1

set

Arguments: <name> <value> [value]...

Array compatible

Stores a variable. These variables are saved between sessions, and are unique per-tag. If used in a custom command, they are unique per-guild. If multiple values are specified, an array is created.

Example Input:
{set;testvar;This is a test var}
Example Output:

shuffle

Arguments: [array]

Array compatible

Shuffles the args the user provided, or the provided array.

Example Input:
{shuffle} {args;0} {args;1} {args;2}
Example Output:
Input: one two three
Output: three one two

space

Arguments: [length]

Will be replaced by a specified number of spaces.

Example Input:
{space;4}Hello, world!
Example Output:
Hello, world!

substring

Arguments: <text> <start> [end]

Returns a chunk of text between the start and end indexes. If end is not specified, it assumes the length of the text.

Example Input:
Hello {substring;world;2;3}!
Example Output:
Hello r!

switch

Arguments: <arg> <case1> <then1> [case2] [then2].. [default]

Finds the case that matches arg and returns the following then.If there is no matching case and default is specified,default is returned. If not, it returns blank.

Example Input:
{switch;{args;0};yes;Correct!;no;Incorrect!;That is not yes or no}
Example Output:
Correct!

throw

Arguments: <error>

Throws an error.

Example Input:
{throw;Custom Error}
Example Output:
`Custom Error`

time

Arguments: [format]

Returns the current time, in UTC+0. If a format code is specified, the date is formatted accordingly. Leave blank for default formatting. See the moment documentation for more information.

Example Input:
It's currently {time;YYYY/MM/DD HH:mm:ss}
Example Output:
It's currently 2016/01/01 01:00:00

trim

Arguments: <text>

Trims whitespace and newlines before and after the provided text.

Example Input:
{trim; trimmed! }
Example Output:
trimmed!

upper

Arguments: <text>

Returns string as uppercase

Example Input:
{upper;this will become uppercase}
Example Output:
THIS WILL BECOME UPPERCASE

uriencode

Arguments: <text>

Encodes a chunk of text in URI format. Useful for constructing links.

Example Input:
​{uriencode;Hello world!}
Example Output:
Hello%20world!

useravatar

Arguments: [user] [quiet]

Returns the user's avatar. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your avatar is {useravatar}
Example Output:
Your avatar is (avatar url)

usercreatedat

Arguments: [format] [user] [quiet]

Returns the date the user was created, in UTC+0. If a format code is specified, the date is formatted accordingly. Leave blank for default formatting. See the moment documentation for more information. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your account was created on {usercreatedat;YYYY/MM/DD HH:mm:ss}
Example Output:
Your account was created on 2016/01/01 01:00:00.

userdiscrim

Arguments: [user] [quiet]

Returns the user's discriminator. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your discrim is {userdiscrim}
Example Output:
Your discrim is 1234

usergame

Arguments: [user] [quiet]

Returns the game the user is playing. If the user isn't playing a game, returns the word 'nothing'. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
You are playing {usergame}
Example Output:
You are playing with bbtag

usergametype

Arguments: [user] [quiet]

Returns how the user is playing the game (playing, streaming). If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
You're {usergametype} right now!
Example Output:
You're playing right now!

userid

Arguments: [user] [quiet]

Returns the user's ID. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your id is {userid}
Example Output:
Your id is 123456789123456

userjoinedat

Arguments: [format] [user] [quiet]

Returns the date the user joined the current guild, in UTC+0. If a format code is specified, the date is formatted accordingly. Leave blank for default formatting. See the moment documentation for more information. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your account joined this guild on {userjoinedat;YYYY/MM/DD HH:mm:ss}
Example Output:
Your account joined this guild on 2016/01/01 01:00:00

username

Arguments: [user] [quiet]

Returns the user's name. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your username is {username;stupid;this can be anything}
Example Output:
Your username is stupid cat

usernick

Arguments: [user] [quiet]

Returns the user's nickname. If it doesn't exist, returns their username instead. If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your nick is {usernick}
Example Output:
Your nick is cat

userstatus

Arguments: [user] [quiet]

Returns the status of the specified user ('online', 'idle', 'dnd', or 'offline'). If name is specified, gets that user instead. If quiet is specified, if a user can't be found it will simply return the name

Example Input:
Your are currently {userstatus}
Example Output:
Your are currently online

void

Arguments: [anything]

Parses its inner tags, but doesn't return anything.

Example Input:
{void;This won't be outputted!}
Example Output:

Array

Functions designed specifically for arrays.

isarray

Arguments: <text>

Determines whether the provided text is a valid array.

Example Input:
{isarray;["array?"]} {isarray;array?}
Example Output:
true false

join

Arguments: <array> <text>

Joins the elements of an array together with the provided text.

Example Input:
{join;["this", "is", "an", "array"];!}
Example Output:
this!is!an!array

pop

Arguments: <pop>

Returns the last element in an array. If used with {get} or {aget}, this will remove the last element from the array as well.

Example Input:
{shift;["this", "is", "an", "array"]}
Example Output:
this

push

Arguments: <array> <values>...

Pushes values into an array. If used with {get} or {aget}, this will update the original variable. Otherwise, it will simply output the new array.

Example Input:
{push;["this", "is", "an"];array}
Example Output:
["this","is","an","array"]

shift

Arguments: <array>

Returns the first element in an array. If used with {get} or {aget}, this will remove the first element from the array as well.

Example Input:
{shift;["this", "is", "an", "array"]}
Example Output:
this

slice

Arguments: <array> <start> [end]

Grabs elements between the zero-indexed start and end points (inclusive).

Example Input:
{slice;["this", "is", "an", "array"];1}
Example Output:
["is", "an", "array"]

sort

Arguments: <array> [descending]

Sorts the provided array in ascending order. If descending is provided, sorts in descending order. If {get} or {aget} are used, will modify the original array.

Example Input:
{sort;[3, 2, 5, 1, 4]}
Example Output:
[1,2,3,4,5]

splice

Arguments: <array> <start> [deleteCount] [items]...

Removes deleteCount elements (defaults to all) starting at index start from the specified array. Then, adds each subsequent item at that position in the array. Returns the removed items.

Example Input:
{set;array;["this", "is", "an", "array"]} {splice;{get;array};1;1;was} {get;array}
Example Output:
["is"] ["this","was","an","array"]

split

Arguments: <text> <splitter>

Splits text using the provided splitter, and the returns an array.

Example Input:
{split;Hello! This is a sentence.;{space}}
Example Output:
["Hello!","This","is","a","sentence."]

Examples

Tags can be combined, nested, and used together to create powerful commands. Here are some examples of existing tags.

waifu
  • stupid cat#8160

    b!t uwaifu stupid cat

  • blargbot#0128
    BOT

    ❤ I'd rate stupid cat as 9.5/10 ❤

{if;
  >;
  {argslength};
  0;
  {set;
    waifuhash;
    {hash;
      {userid;
        {args}}
    }
  }
  {set;
    waifurating;
    {math;
      %;
      {if;
        <;
        {get;waifuhash};
        0;
        {math;*;{get;waifuhash};-1};
        {get;waifuhash}
      };
      100
    }
  }
  {set;
    waifumoji;
    {if;
      <=;
      {get;waifurating};
      60;
      💔;
      ❤
    }
  }
  {get;waifumoji} I'd rate {usernick;{args}} as {math;/;{get;waifurating};10}/10 {get;waifumoji};
  Calculate the waifu rating of any user. Use waifu if you want to use any word.
Usage: `uwaifu <name>`
sleepykitty
Here's your sleepy kitty, {username}! {randchoose; http://i.imgur.com/zuhDRDT.gif ;http://i.imgur.com/0Jouxni.gif ;http://i.imgur.com/xP4Twvo.gif ;http://i.imgur.com/EDBtvW4.gif ;http://i.imgur.com/Pr0ovhy.gif ;http://i.imgur.com/CNh2Jen.gif ;http://i.imgur.com/lYTc1f3.gif ;http://i.imgur.com/9125v7e.gif ;http://i.imgur.com/d1cGI9H.gif ;http://i.imgur.com/Jdxjdgm.gif ;http://i.imgur.com/0ixS2gi.gif ;http://i.imgur.com/p8soxvZ.gif ;http://i.imgur.com/bssgLxK.gif ;http://i.imgur.com/tLVte5N.gif ;http://i.imgur.com/PyvrGTI.gif ;http://i.imgur.com/Hfh4LQH.gif ;http://i.imgur.com/mDTWNSY.gif ;http://i.imgur.com/fc3BsdW.gif ;http://i.imgur.com/vTXqGdS.gif ;http://i.imgur.com/DzMOiZx.gif ;http://i.imgur.com/IWa6N2B.gif ;http://i.imgur.com/YxYpOHc.gif ;http://i.imgur.com/YwLHV2L.gif}
f
  • stupid cat#8160

    b!t f

  • blargbot#0128
    BOT

    stupid cat has paid their respects. Total respects given: 13

{fallback;0}{set;respects;{math;+;{get;respects};1}} **{usernick}** has paid their respects. Total respects given: **{get;respects}**