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
  • Settings
  • Loop Count
  • Timeout
  • Limitations
  • Loop Variables
  • Stop a Loop Action

Was this helpful?

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

Run a Loop

Last updated 9 months ago

Was this helpful?

Loops allow you to repeat connected actions and conditions a set amount of times. You can change the number of times a loop is run by setting the loop count with a number or variable. Actions and conditions connected to the Loop X Times block will then be run that many times. Once the loop has finished actions and conditions connected to the 'After Loop' block will be run like normal. This block will open a world of possibilities for users to explore.

Settings

Loop Count

Timeout

This setting lets you specify the timeout between loop iterations. This means that once one iteration is completed, the bot will wait the provided amount of ms before starting the next iteration. The minimum timeout is 10 milliseconds and the maximum is 600000 milliseconds (10 minutes). Remember that 1 seconds equals to 1000 milliseconds (or ms).

Limitations

There are a few limitations on loops to discourage abuse of the system:

  • Loops have a minimum timeout of 10 ms between each loop and a maximum of 600000 milliseconds (10 minutes).

  • You can not run loops inside of loops.

  • A max loop count of 1000 exists.

These limitations may change as we monitor how people are using loops.

Loop Variables

This action comes with two variables, they are:

Variable
Description

{loop_count}

Returns the current loop count. Starts at 1.

{loop_index}

Returns the current loop index. Starts at 0 and is useful for when looping through collections.

Stop a Loop Action

The "Loop count" section will determine the number of times the actions that follow should repeat. By default this is set to a count of 5, however, you can loop actions up to 1000 times. All can be used. If you want to loop through all values of a collection, you can use the {lengthOfCollection()} variable to loop as many times as the length of the collection.

Loops have a unique action that can be run to stop any running loop. This action can be used with conditions to conditionally stop a loop.

variables
Stop a Loop