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
  • Custom Variable
  • Targets
  • User Target
  • Channel Target
  • Text Variables
  • Value
  • Number Variables
  • Value
  • Collection Variables
  • Collection Operation
  • Object Variables
  • Key
  • Value

Was this helpful?

  1. Custom Commands & Events
  2. Actions
  3. Custom Variable Actions

Set Variable

Last updated 1 month ago

Was this helpful?

The Set Variable action when triggered sets or changes the value of any custom variable. It can be referenced in any action or condition throughout your bot's commands and events. All variables and options can be used in the content of the value.

Custom Variable

In this section, you can manage which variable the bot will set. You can select from a dropdown that will display the bot's variables. Variables on this list can be added, edited, and removed using the Data Storage module.

Targets

When using the Run Equation on Variable action on a user or channel variable, a Targets section will be displayed. This will allow you to set the user or channel to set the variable for.

User Target

User Target only appears for user variables.

The Set Variable action has three options that change to whom the variable of the action is stored. Below you can find detailed information about each option and how it can be used.

By selecting this option your Variable will be stored to the user who used the most recent interaction; for example, the most recent button press, select menu choice, command run or the user who triggered the custom event.

In commands, by selecting this option your Variable will be stored to a user selected in a user option.

User Option

Here you can set the option variable for the User option (purple blocks) you are using. These can be easily added through the variable selector by clicking the Clipboard button.

By selecting this option your Variable will be stored to a user specified via their user ID.

User ID

Channel Target

Channel Target only appears for channel variables.

The Set Variable action has two options that change to which channel the variable of the action is stored. Below you can find detailed information about each option and how it can be used.

By selecting this option your Variable will be stored to a channel specified via its ID.

Channel ID or Variable

By selecting this option your Variable will be stored to the channel the most recent interaction was used in; for example, the most recent button press, select menu choice, command run or the channel of the custom event.


Some Variable Types will display differently than others. Below you may find some general information about each type. Click on its name for more information on setting it.

Variable Type
Information

A text variable stores a string of text for a server or the bot.

A number variable stores a number for a server or the bot.

A collection variable stores multiple text values as an array. These arrays can be managed by their values and the positions of values.

An object variable stores a string of text by setting key value pairs. These strings can be accessed by dot notations.

Text Variables

A text variable stores a string of text for a server or the bot.

Value

The value of the action is the actual message that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Number Variables

A number variable stores a number for a server or the bot.

Value

The value of the action is the actual number that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Collection Variables

Collections start at position 0.

A collection variable stores multiple values as an array. These arrays can be managed by their values and the positions of values.

Collection Operation

The manipulation type with the provided 'Custom Variable' field. There are several operations to choose from. Below you can find detailed information about each operation and how it can be used.

The Push value to front operation allows you to add a value at the first position, 0, of a collection. This will increase the position of each value ahead of it by 1.

Value

The value of the action is the actual message or number that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Examples

Before
Value
After

[Value 0,Value 1]

Hello

[Hello,Value 0,Value 1]

[Hello,Value 0,Value 1]

{user_name}

[User,Hello,Value 0,Value 1]

[User,Hello,Value 0,Value 1]

I was stored from {channel_name}

[I was stored from general,User,Hello,Value 0,Value 1]

The Push value to end operation allows you to add a value at the last position of a collection.

Value

The value of the action is the actual message or number that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Examples

Before
Value
After

[Value 0,Value 1]

Hello

[Value 0,Value 1,Hello]

[Value 0,Value 1,Hello]

{user_name}

[Value 0,Value 1,Hello,User]

[Value 0,Value 1,Hello,User]

I was stored from {channel_name}

[Value 0,Value 1,Hello,User,I was stored from general]

The Remove first value operation allows you to remove a value at the first position, 0, of a collection. This will decrease the position of each value ahead of it by 1.

Examples

Before
After

[I was stored from general,User,Hello,Value 0,Value 1]

[User,Hello,Value 0,Value 1]

[User,Hello,Value 0,Value 1]

[Hello,Value 0,Value 1]

[Hello,Value 0,Value 1]

[Value 0,Value 1]

The Remove last value operation allows you to remove a value at the last position of a collection.

Examples

Before
After

[Value 0,Value 1,Hello,User,I was stored from general]

[Value 0,Value 1,Hello,User]

[Value 0,Value 1,Hello,User]

[Value 0,Value 1,Hello]

[Value 0,Value 1,Hello]

[Value 0,Value 1]

The Set value at position operation allows you to add a value at any position of a collection. This will replace the old value of the collection at that position.

Value

The value of the action is the actual message or number that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Position

The position of the action is the numbered location of the value you're adding. Collection values start at 0 and increase by 1 for each value before them. You can use any variable or option in the content of this position. These can be easily added through the variable selector by clicking the Clipboard button.

Examples

Before
Value
Set at Position
After

[Value 0,Value 1]

Hello

0

[Hello,Value 1]

[Hello,Value 1]

{user_name}

2

[Hello,Value 1,User]

[Hello,Value 1,User]

I was stored from {channel_name}

1

[Hello,I was stored from general,User]

The Remove value at position operation allows you to remove a value at any position of a collection. This will decrease the position of each value ahead of it by 1.

Position

The position of the action is the numbered location of the value you're removing. Collection values start at 0 and increase by 1 for each value before them. You can use any variable or option in the content of this position. These can be easily added through the variable selector by clicking the Clipboard button.

Examples

Before
Position
After

[Hello,Value 0,User,Value 1,I was stored from general]

4

[Hello,Value 0,User,Value 1]

[Hello,Value 0,User,Value 1]

2

[Hello,Value 0,Value 1]

[Hello,Value 0,Value 1]

0

[Value 0,Value 1]

The Remove value in collection operation allows you to remove the first occurrence of a value in a collection. This will decrease the position of each value ahead of it by 1.

Value

The value of the action is the actual message or number that the bot should remove from the collection when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

Examples

Before
Value
After

[Value 0,Value 1,Hello,User,I was stored from general]

I was stored from {channel_name}

[Value 0,Value 1,Hello,User]

[Value 0,Value 1,Hello,User]

Hello

[Value 0,Value 1,User]

[Value 0,Value 1,User]

Value 1

[Value 0,User]

The Clear a collection operation allows you to empty, or remove all values of, a collection variable.

Examples

Before
After

[Value 0,Value 1,Hello,User,I was stored from general]

[]

[Value 0,Value 1,Hello,User]

[]

[Value 0,Value 1,User]

[]

Object Variables

Key

Value

Here you can set the ID of the user to set a variable for. You can do this by pasting an ID directly from Discord (learn how ) or using a variable that returns a user ID. These can be easily added through the variable selector by clicking the Clipboard button.

Here you can set the ID of the channel to set a variable for. You can do this by pasting an ID directly from Discord (learn how ) or using a variable that returns a channel ID. These can be easily added through the variable selector by clicking the Clipboard button.

An variable stores a string of text by setting key value pairs. These strings can be accessed by dot notations.

The key of the property to change the value from. You can use any existing or new key from the object variable to set a value.

The value of the action is the actual message that the bot should store when the action is triggered. You can use any or in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.

here
here
object
object
variable
option
Text Variables
Number Variables
Collection Variables
Object Variables