Variables
Last updated
Last updated
The available variables in your command or event may vary depending on the action, custom variables you have and the event you might be using. Here you may find some general information on what they are and how to use them.
You can add a target to your variable to get data of a specific user, channel, role or server (more targeting options are available when using ). To do so, add square brackets []
at the very end of your variable*. Make sure to add a valid ID, variable or option. See below for more info.
* Targeting is slightly different for : the square brackets go before the first dot. For example, {Channel[ID].name}
instead of {Channel.name[ID]}
.
You can use a plain ID as a target. This means the variable will always return the value of the same user, channel or role.
Below are some examples:
{user_icon[136327647792726016]}
{user_joinedAt[136327647792726016]}
{channel_name[1021852614725480448]}
In commands you can use an option for your target (make sure it's a valid variable type: you need to use user options if you want to target a user using a option). The variable name should be inside your square brackets []
, without any curly brackets {}
around it, and preceded by option_
.
Below are some examples:
{user_icon[option_user]}
{user_joinedAt[option_player]}
{channel_name[option_channel]}
Lastly, you can also use other variables that contain an ID. Unlike options, make sure to paste the full variable inside your square brackets []
, including the curly brackets {}
.
Below are some examples:
{user_icon[{bot_id}]}
{user_joinedAt[{api.response.id}]}
{channel_name[{BGVAR_my_custom_variable}]}
Some variables in BotGhost allow you to access properties of a larger object through dot notation. These variables start with a Capital letter and give you access to all the properties available on their respective Discord.js objects. Currently these objects are available:
{Guild}
{Channel}
{Member}
{User}
{Role}
{Invite}
The guild variable gives you access to the properties of the guild (server) a command was used in or an event was triggered in. You can also access a specific guild by enclosing a guild ID in square brackets ({Guild[822426820447567872].name}
).
For example:
{Guild.name}
{Guild[822426820447567872].name}
{Guild.roles}
{Guild.bans}
{Guild.icon}
The channel variable gives you access to the properties of the channel a command was used in or an event was triggered in. You can also access a specific channel by enclosing a channel ID in square brackets ({Channel[1111802548312096778].name}
).
For events this will be the channel associated with the event. For voice events this will be a voice channel.
For example:
{Channel.name}
{Channel[1111802548312096778].name}
{Channel.type}
{Channel.id}
{Channel.position}
The member variable gives you access to the properties of the guild member who used a command or triggered an event. You can also access a specific member by enclosing a member ID in square brackets ({Member[136327647792726016].avatar}
).
For example:
{Member.user.username}
{Member[136327647792726016].user.username}
{Member.avatar}
{Member.roles}
{Member.presence}
The user variable gives you access to the properties of the user who used a command or triggered an event. You can also access a specific user by enclosing a user ID in square brackets ({User[136327647792726016].avatar}
).
For example:
{User.username}
{User.globalName}
{User.avatar}
{User.banner}
The role variable gives you access to the properties of a specific role, that can be either provided by a role ID or a role option. To access the object, enclosing a role ID in square brackets ({Role[905462520519745537].color}
).
For example:
{Role[905462520519745537].icon}
{Role[option_role].name}
{Role[{event_role_id}].hoist}
{Role[{my_variable}].position}
The invite variable gives you access to the properties of a specific invite to the server. You can access its information by enclosing a invite in square brackets ({Invite[botghost].expiresAt}
).
For example:
{Invite[botghost].createdAt}
{Invite[9UPM6S4xyA].channel}
{Invite[{BGVAR_custom_variable}].maxUses}
{Invite[{my_variable}].uses}
Below are all basic variables that you can use in the command or event.
{user}
Returns the mention of the user
{server}
Returns the server name
{channel}
Returns the mention of the channel
{^ROLE NAME}
eturns the mention of a role on role name
{#CHANNEL NAME}
Returns the name of the channel
{channel_type}
GUILD_TEXT
{channel_id}
Returns the ID of the channel
{server_members}
Returns the server member count
{server_icon}
Returns a URL to the server icon
{server_id}
Returns the ID of the server
{server_owner}
Returns the mention of the server owner
{server_owner_id}
Returns the ID of the server owner
{user_icon}
Returns the icon of a user
{user_name}
Returns the user name of a user
{user_id}
Returns the ID of a user
{user_tag}
Returns the user tag of a user
{user_discriminator}
Returns the discriminator of a user
{user_createdAt}
Returns the creation date of a user
{user_joined}
Returns the join date of the server from a user
{user_displayName}
Returns the display name of a user
{user_status}
Returns the status of a user
{random[min,max]}
Returns a random number between min and max
{randomCharacters(3)}
Returns a random set of numbers
{charCount(TEXT)}
Returns the character count of a string of text
{time_now}
Returns a timestamp of the current time
{time_ahead_h_HOURS}
Returns a timestamp of a certain number of hours ahead
{time_ahead_m_MINS}
Returns a timestamp of a certain number of minutes ahead
{time_now_unix}
Returns a unix combination of the current time
{time_ahead_unix_h_HOURS}
Returns a unix combination of a certain number of hours ahead
{time_ahead_unix_m_MINS}
Returns a unix combination of a certain number of minutes ahead
{time_ahead_unix_s_SECS}
Returns a unix combination of a certain number of seconds ahead
{ISO_to_UNIX[Timestamp]}
Converts an ISO timestamp to an UNIX timestamp
{UNIX_to_ISO[Timestamp]}
Converts an UNIX timestamp to an ISO timestamp
{HEX_to_DECIMAL[HEX]}
Converts a hex code to a decimal
{solve_equation[1+1]}
Solve a math equation
{previous_numbers(10)}
Returns all previous numbers of a given number
{bot_id}
Returns the ID of the bot
Those variables can be used with the error handler block or success / error handles when something goes wrong with your tree.
{error_reason}
Returns the reason why the error occurred.
{error_message}
Returns the error message associated with the action the error occurred from.
{error_block}
Returns name of the block which the error occurred in.
Through dot notation, you are able to access all the properties of the .
For a full list of properties make sure to checkout the properties section on the .
Through dot notation, you are able to access all the properties of the . For voice events, you can access properties of the .
For a full list of properties make sure to checkout the properties section on the .
Through dot notation, you are able to access all the properties of the .
For a full list of properties make sure to checkout the properties section on the .
Through dot notation, you are able to access all the properties of the .
For a full list of properties make sure to checkout the properties section on the .
Through dot notation, you are able to access all the properties of the .
For a full list of properties make sure to checkout the properties section on the .
Through dot notation, you are able to access all the properties of the
For a full list of properties make sure to checkout the properties section on the
Returns the of the channel