Global Variables

How to set a global variable

Setting a global variable is a variable that will work for everyone, everywhere, however you want it to.

The variables you see on the "Bot Variables" page aren't anyone's specific data. It only shows the default value you had set for the variable

The API endpoint needed for this looks like:

Set the value of a variable

POST https://www.charm-cord.com/database/setvar

Query Parameters

NameTypeDescription

key*

String

Your authorization key that you recieved the first time you made a variable

variable*

String

The name of the variable

value*

Any

The value that you want to give to the variable

{
    "Status": "Successfully updated a variable"
}

Get the value of a variable

GET https://www.charm-cord.com/database/getvar

Query Parameters

NameTypeDescription

key*

String

Your authorization key that you recieved the first time you made a variable

variable*

String

The name of the variable

{
    "value": "String"
}

BotGhost setup

If you're following along with this guide, the first thing you should do is create a new custom command on your BotGhost bot. To practice setting up, we will have a variable named "count" that will count each time a specific command is used

Next thing you should do is import the API Request block. This will be used to get the current count

We're not going to go into how to use mutliple api endpoints to do addition then set it to the variable, we'll just set it manually to get a feeling of what it does.

You can use CharmCord's math tool if you need to do any expressions to be solved

In the next example, we're using both setvar and getvar. The first block is setting the count variable to 3 and the second block is grabbing the new variable from the database

Last updated