Variables & Directives (& You) - A Beginner's Guide

If you're a Botisimo user hopefully you know about our Documentation section (if not, it's right here: https://docs.botisimo.com/en/latest/

And you know what you can find in the Documentation? If you've read the title then you can probably guess: Variables & Directives!

Variables and directives can make your commands and responses more dynamic and add a little spice to things.

What's the difference between them?

Largely, variables output things, and directives do things. (It's a lot more nuanced than that but you get what I'm saying)

If you're on the Docs page, you can find the Variables and Directives over on the side of the page, and they also have their own individual pages.

Image 608

Here's an example of a Variable:

Let's say I want a command that rolls a dice. We can do that with the RNG variable.

Image 609

Here we can see that this variable resolves a random number between given numbers.

In order to make it a command, we're gonna have to go to our Commands section on Botisimo and click "Create New"

Image 610

In this example, I'm calling my command "!d20" and entering into the Response Field:

Roll result: $(rng 1 20)

It should look something like this:

Image 611

And here's what it looks like when I test it out:

Image 612

Great!

Now let's show an example of a Directive.

Let's say I want a command that costs currency to use. For that, I'd use the Cost directive.

Image 613

For this one, I'm gonna call my command "whoops" and put this in the Response:

$[cost 20] You tripped and 20 of your Bot Bucks fell in a ditch. Sorry.

Kinda how it looks right here:

Image 614

And here's how it looks when I test it out, complete with Before-and-After currency totals:

Image 615

As you can see, I've lost 20 of my Bot Bucks, due to that darn ditch.

And guess what! You can put variables and directives in the same command! How about that!

If you look in the example below, you can see that I've added a $[cost] of 20 currency to my already existing !d20 command.

Image 616

So if I were to use my !d20 command, it would cost me 20 of my channel's currency, and it should look like this:

Image 617

Just like that! As you can see, rolling the d20 cost me 20 Bot Bucks, and boy howdy were those some terrible rolls.

Now, why would I wanna charge people to roll a dice? I dunno! It's just an example. I want to show you that you can use Variables and Directives to do some real fancy stuff with your commands.

What I've shown you is a very simple example of what's possible - you can do a lot more advanced stuff, especially with javascript expressions, but this is meant to be a very basic and introductory lesson.

And guess what: This article comes in VIDEO FORM! You can watch it right here:

Youtube video



So! Try them out! Have fun with these! Do your best! And if you ever need help, hit up our Knowledge Base or email us a support@botisimo.com

Is this article helpful for you?