BotGhost Documentation
Support ServerYouTubeMarketplaceBotGhost PremiumSign in
  • Welcome to BotGhost
  • Guidelines & Privacy
  • Changelogs 2025
    • Changelogs 2024
    • Changelogs 2023
  • BotPanel Documentation
  • Getting Started
    • Create Your First Bot
      • Create Your Second Bot
    • Invite Your Bot
    • Standard Practices
      • Advanced Practices
    • Mobile Application (PWA)
  • Support
    • BotGhost Support
    • Frequently Asked Questions
  • Premium & Priority Hosting
    • Priority Hosting
    • Our Premium Features
    • Plans & Payment Methods
    • Manage Your Subscription
    • Upgrade Your Bot
    • Refund & Cancellation Policy
    • Beta Features
  • General Settings and Collaboration
    • Settings
    • Collab
    • Status
    • Active Developer Badge
    • Marketplace
  • Custom Commands & Events
    • Command & Event Builder
      • Sharing Commands and Events
      • Advanced Options
    • Actions
      • Message Actions
        • Send or Edit a Message
          • Button
          • Select Menu
        • Edit a Button or Select Menu
        • Send a Form
        • Delete a Message
        • Publish a Message
        • React to a Message
        • Pin a Message
      • Custom Variable Actions
        • Set Variable
        • Run Equation on Variable
        • Delete Variable
      • API Actions
        • Send an API Request
        • Execute an IFTTT Trigger
      • Loop Actions
        • Run a Loop
        • Stop a Loop
      • Voice Actions
        • Join a Voice Channel
        • Leave a Voice Channel
        • Voice Move a Member
        • Voice Kick a Member
        • Voice Mute or Unmute a Member
        • Voice Deafen or Undeafen a Member
      • Role Actions
        • Add Roles
        • Remove Roles
        • Create a role
        • Delete a role
        • Edit Role
      • Channel Actions
        • Create a channel
        • Edit a channel
        • Delete a channel
      • Thread and Forum Actions
        • Create a Thread
        • Edit a Thread
        • Delete a Thread
      • Server Actions
        • Kick a member
        • Ban a member
        • Timeout a member
        • Change a members nickname
        • Purge Messages
        • Create Server Invite
      • Other Actions
        • Wait before running another action
        • Manipulate some text
        • Send an error log message
        • Set a unique variable
        • Change the Bot's Status
        • Note
      • [LEGACY] Reply Actions
        • Plain Text Reply
        • Embed Reply
        • Random Reply
        • Send a message to a channel
        • Direct Message a User
        • Send a Message with attached buttons
          • Buttons
        • Send a message with a select menu
          • Menu Option
    • Conditions
      • Comparison Condition
      • Permission Condition
      • Chance Condition
      • Channel Condition
      • Role Condition
      • User Condition
      • Premium Check Condition
    • Options
      • Text Option
      • Number Option
      • User Option
      • Channel Option
      • Role Option
      • Choice Option
      • Attachment Option
    • Events
      • Timed Events
      • Webhooks
    • Data Storage
      • Collections
      • Objects
    • IFTTT
    • Variables
  • Server Management
    • Moderation
    • Discord Automod
    • Tickets
    • Welcomer
    • Verification
    • Statistic Channels
    • Modmail
    • Auto-React
    • Sticky Roles
    • Emoji Manager
    • Polls Filter
    • Automod
    • Logging
  • Messages
    • Timed Messages
    • Reaction Roles
    • Autoresponder
    • Embed Builder
    • Sticky Messages
    • Polls
    • Global Chat
    • Media Channels
  • AI
    • ChatGPT
    • Image Generation
  • Game Integrations
    • Roblox Verification
  • Social Integrations
    • YouTube
    • Twitch
  • Community Engagement
    • Leveling
    • Temp Voice Channels
    • Suggestions
    • Invite Tracker
    • Starboard
    • Question Of The Day
    • Giveaways
  • Fun Modules
    • Economy & Minigames
    • Birthdays
    • Counting
  • Utility
    • Translation
    • Weather
Powered by GitBook
On this page
  • Targeting
  • Plain ID
  • Options
  • Variables Containing an ID
  • Storing Custom Data
  • Storing Data across all commands and events
  • Storing Data in a command or event
  • Variables
  • Object Variables
  • Collection / Array Variables
  • Basic Variables
  • Error Variables
  • Other Variables

Was this helpful?

  1. Custom Commands & Events

Variables

Last updated 22 days ago

Was this helpful?

Variables allow you to store data from API requests, action outputs, custom data and more. Variables can be used in almost every field of the actions and conditions .

The available variables in your command-builder or event-builder may vary depending on the action, custom variables you have, API requests you use, and the event you might be using in case you are using the event builder. Here you may find some general information on what they are and how to use them.

Targeting

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 Object Variables). 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]}.

Plain 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]}

Options

In custom 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]}

Variables Containing an ID

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}]}

Storing Custom Data

Storing Data across all commands and events

Storing Data in a command or event

You can also store data only in a specific command / event execution, meaning that once the execution of the command / event is completed, saved data will be deleted. This is useful to easily store temporary data. Check out the Set a unique variable page to learn more.

Variables

Object Variables

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}

Guild Variable

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}

Channel Variable

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}

Member Variable

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}

User Variable

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}

Role Variable

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}

Invite Variable

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}

Collection / Array Variables

BotGhost offers some variables you can use for any array or collection (even from an API response), which allow you to retrieve specific information of the collection.

Variable
Information

{lowestValue({BGVAR_collection})}

Returns the lowest value in a collection.

{highestValue({BGVAR_collection})}

Returns the highest numerical value in a collection.

{lengthOfCollection({BGVAR_collection})}

Returns the length of a collection.

{valueAtPosition({BGVAR_collection}),[2]}

Returns the value at a specific position in the collection. Positions start at 0.

{positionOfValue({BGVAR_collection}),[hello]}

Returns the position of a value.

{collectionCharacterLength({BGVAR_collection})}

Returns the total character length of a collection.

{printAllValues({BGVAR_collection}),[Hello $value]}

Prints all values in a collection. The text returned can be set in the []. Use $value to print the value, and $index to display the index of the value shown.

{getRandomFromCollection({BGVAR_collection})}

Returns a random value from the collection.

Basic Variables

Variable
Details
Supports Targets
Example Output

{user}

Returns the mention of the user

<@1085541861692813332>

{server}

Returns the server name

BotGhost👻

{channel}

Returns the mention of the channel

<#879733469452836864>

{^ROLE NAME}

Returns the mention of a role on role name

<@&1190298492661420163>

{#CHANNEL NAME}

Returns the mention of a channel on channel name

<#879733469452836864>

{channel_name}

Returns the name of the channel

general-chat

{channel_type}

GUILD_TEXT

{channel_id}

Returns the ID of the channel

879733469452836864

{first_channel_id}

Returns the first channel ID of the server

879733469452836864

{server_members}

Returns the server member count

12

{server_icon}

Returns a URL to the server icon

{server_id}

Returns the ID of the server

822426820447567872

{server_owner}

Returns the mention of the server owner

<@136327647792726016>

{server_owner_id}

Returns the ID of the server owner

136327647792726016

{user_icon}

Returns the icon of a user

{user_name}

Returns the user name of a user

tomtoise

{user_id}

Returns the ID of a user

136327647792726016

{user_tag}

Returns the user tag of a user

{user_discriminator}

Returns the discriminator of a user

#4001

{user_createdAt}

Returns the creation date of a user

Fri Apr 08 2022 13:51:34 GMT+0000 (Coordinated Universal Time)

{user_joined}

Returns the join date of the server from a user

Fri Apr 08 2022 13:51:34 GMT+0000 (Coordinated Universal Time)

{user_displayName}

Returns the display name of a user

Tomtoise

{user_status}

Returns the status of a user

online

{random[min,max]}

Returns a random number between min and max

6

{isNumber(TEXT)}

Checks if a string of text is a number

true

{randomCharacters(3)}

Returns a random set of numbers

hIVzhLgwIb

{charCount(TEXT)}

Returns the character count of a string of text

16

{isBot}

Checks if a user is a bot

true

{bot_serverCount}

Returns the server count of the bot

12

{user_name_encoded}

Returns a URL encoded version of a user name, useful when sending the user's name in API request's URLs

Tomtoise

{time_now}

Returns a timestamp of the current time

<t:1724181552:R>

{time_ahead_h_HOURS}

Returns a timestamp of a certain number of hours ahead

<t:1724181552:R>

{time_ahead_m_MINS}

Returns a timestamp of a certain number of minutes ahead

<t:1724181552:R>

{time_now_unix}

Returns a unix combination of the current time

1724181974

{time_ahead_unix_h_HOURS}

Returns a unix combination of a certain number of hours ahead

1724181974

{time_ahead_unix_m_MINS}

Returns a unix combination of a certain number of minutes ahead

1724181974

{time_ahead_unix_s_SECS}

Returns a unix combination of a certain number of seconds ahead

1724181974

{encode_text[TEXT]}

Returns url encoded text for API requests

Hello%2C%20how%20are%20you

{ISO_to_UNIX[Timestamp]}

Converts an ISO timestamp to an UNIX timestamp

1724181974

{UNIX_to_ISO[Timestamp]}

Converts an UNIX timestamp to an ISO timestamp

2024-02-26T20:28:40.902000+00:00

{HEX_to_DECIMAL[HEX]}

Converts a hex code to a decimal

1329119

{solve_equation[1+1]}

Solve a math equation

2

{previous_numbers(10)}

Returns all previous numbers of a given number

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

{numberWithCommas[1000000]}

Formats large numbers with commas

1,000,000

{numberWithDots[1000000]}

Formats large numbers with dots

1.000.000

{bot_id}

Returns the ID of the bot

1085541861692813332

{hasRole([ROLE_ARRAY])}

Checks if the user has a set of roles

true

{isChannel([CHANNEL_ARRAY])}

Checks if the action is executed in a channel

true

{subString(Hello World),[0,5]}

Returns a substring of a given string

Hello

{toUpperCase(hello)}

Returns the given text to upper case

HELLO

{escape_characters[TEXT]}

Escapes the text provided to make it usable for API requests

Hello\nLine break

{websocket_ping}

Returns the ping of the bot

36 ms

{interaction_id}

Returns the ID of the interaction with the bot. This can be used in API requests to reply to interactions

1313779673350980230

{interaction_token}

Returns the token of the interaction with the bot. This can be used in API requests to reply to

A string of characters

Error Variables

Those variables can be used with the error handler block or success / error handles when something goes wrong with your tree.

Variable
Description

{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.

Other Variables

You can view the available variables by checking the clipboard in the top right corner of each action. In the picture, the clipboard is indicated by the red arrow in a Plain Reply action.

The available variables in your command-builder or event-builder may vary depending on the action, custom variables you have, API requests you use, and the event you might be using in case you are using the event builder.

Variables
Details

Event variables

Data storage variables

Form variables

API response variables

Error handler variables

You can use a set of variables when your command or event triggers an error. You can use these variables to get, for example, the error reason. They can be used only below the "Error Handler" red block.

Option variables

Unique variables

Success / error handler variables

You can use a set of variables when your action triggers an error. (If enabled) You can use these variables to get, for example, the error reason, message or action block.

Loop variables

Created channel variables

Created / edited thread variables

Invite variables

Manipulate some text variables

If you want to store data across all commands and events, you can use the , which allows you to store and retrieve data with different types of variables.

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

Below are all basic variables that you can use in the .

Returns the of the channel

BotGhost Helper#4001

Depending on what type you use, you will have an other set of basic variables that you can use to retrieve specific information of the event. Check out the and pages to know more about webhooks and IFTTT variables.

Depending on what you have created, you will have an other set of data storage variables.

Depending on what you name your have, you will have an other set of form response variables.

Depending on what API request you use, you will have an other set of variables.

Depending on your names, you can have option variables in your command builder.

Depending on the that you use in your command or event and their names, you will have a set of unique variables.

You can use a few variables inside of a to get the loop count ({loop_count}) and index ({loop_index}).

Depending on the name of a create a channel action, you can use a set of variables to get the channel name, ID and type. Check out the page for more.

You can create a variable to retrieve the name, ID and more of the created / edited thread. Check out the and pages for more.

You can use a set of variables to get the codes from a created invite link. Check out the page for more.

You can use a variable of a name of your choice to get the result of the action.

data storage
Discord.js Guild Object
Discord.js Wiki
Discord.js Channel Object
Voice Channel
Discord.js Wiki
Discord.js GuildMember Object
Discord.js Wiki
Discord.js User Object
Discord.js Wiki
Discord.js Role Object
Discord.js Wiki
Discord.js Invite Object.
Discord.js Wiki.
command or event builder
custom command and event builder
object variables
Create a channel
Create a Thread
Edit a Thread
Create Server Invite
Manipulate some text
type
Webhooks
IFTTT
event
custom variables
form actions
API response
option
unique variables
loop
Clipboard with available variables indicated by the red arrow