Conditions
Last updated
Last updated
Conditions allow you to check values, e.g. to check if the command has been run in a specific channel. This allows to to set unique actions depending on values. Each condition is a different type, such as a chance or channel condition.
In each condition, an else condition will automatically be made. This means, if no condition was met, any actions connected to the else condition will run instead. For example, if you have a channel condition to make sure the command was run in a staff-only channel, and it was not, the else condition will be triggered.
For a quick explanation of each condition block, please see below.
Condition Type | Description & Example |
---|---|
Chance | Your condition will be the % chance of if the connected blocks will run. E.g., 20% will result in your connected blocks running 20% of the time. |
Channel | This will allow you to check if the command or event was ran in a specific channel. For example, you can limit your commands to staff-only channels. |
Comparison | This will let you check any value against another; this includes variables. E.g., you can check if |
Options | If you have any option blocks in your command, you can check what the command executor has selected and run specific actions. |
Permissions | Unlike command permissions, this lets you check the permissions of a user. E.g., you can check the permissions of someone who used a button. |
Role | Similarly to the permissions condition, this lets you check the roles a user has. For example, you can check if the user has an admin role. |
User | A user condition lets you check whether the interacting user is someone specific. E.g., this is useful to see if the interacting user is the ticket opener. |
In any condition block you use, you can toggle whether multiple conditions will run if they are met. By default, the first condition that is met will be triggered, and all other conditions will be ignored. Additionally, every condition block will have a list of existing conditions you have made.
To edit any of your existing conditions, select the condition you wish to edit in the condition's list and simply change the value. In this same menu, you can also delete a condition.
When setting up any condition, you must know how to find an ID. See below if you are unsure.
Useful for economy and utility commands, the chance condition block lets you randomize the actions that are run. For example, with a 20%, 30% and 50% condition (as shown below), my 50% message block is most likely to be shown as it has the highest chance.
Each condition should amount to 100%, else the block may not work as intented.
A channel condition allows you to run specific actions depending on the current channel (e.g., the channel the command was run in). If the current channel does not match any of your conditions, the 'else' condition will trigger.
When adding a new condition to a channel condition block, you must enter a channel ID. Channel IDs are a unique code per channel on Discord, and they are used so that bots understand which channel to take action on. Since some channels can have the same name, IDs distinguish them.
In the example below, I have added a channel condition. If my command is run in the channel I have selected, my message will send. If not, nothing will happen as I have no blocks in my else condition.
If I wanted a staff-only command, I can use a channel condition. In the following example, I have added my staff channel IDs and connected a send message block. If the command was not run in a staff channel, a message will not be sent as no blocks are attached to my else condition.
Comparison conditions will allow you to compare one value with another. Not only can you check if your first value is equal to the second, but you can also check if it is less than, not equal to, contains, starts with and more!
For example, custom variables can hold data for instances such as a custom economy. You can create a custom variable for storing a user's balance, and from there, you can use a comparison condition to check a user's balance, e.g., if the user's balance is greater than 1,000.
In a comparison condition, as previously mentioned, you can change the way you compare the two values together. For instance, you can check if the first value contains the second value. Or, if your first value is equal to your second. To put that into perspective, here are all of the types that you can select:
Comparison Type | Description |
---|---|
== Equal to | Checks if both values are equal to each other. |
>= Greater than or equal to | Checks if the first value is >= your second value. |
<= Less than or equal to | Checks if the first value is <= your second value. |
!= Is not equal to | Checks if the first value is != your second value. |
< Less than | Checks if your first value is less than your second value. |
> Greater Than | Checks if your first value is greater than your second value. |
() Contains | Checks if your first value contains your second value. |
!() Does not contain | Checks if your first value does not contain your second value. |
$ Starts with | Checks if your first value starts with your second value. |
^ Ends with | Checks if your first value ends with your second value. |
!$ Does not start with | Checks if your first value does not start with your second value. |
!^ Does not end with | Checks if your first value does not end with your second value. |
For both the '() Contains', and '!() Does not contain' types, these can accept both arrays and strings. For instance, you can check if a message contains a word or phrase. Or, if an array contains a value.
Start by figuring our what your first value will be. This will be the value your compare against, such as if this value is equal to another; enter this value in the 'compare value' textbox shown below. Next, place your second value in the 'comparison value' textbox and set your comparison type.
In the example below, once this comparison condition block is executed, the condition will be found as 'hello' is equal to 'HELLO' with the ignore case option enabled. Any blocks I connect to this new condition will run, as opposed to any blocks connected to my else condition.
Unlike comparison values, your compare value will be constant. E.g., you can check if your compare value is equal to, contains or is greater than different comparison values. If you'd like to compare a new compare value against a comparison value, you must make multiple blocks.
Option conditions are only viable if your command has option blocks. An option block is where a user can enter information at the start of their command, such as by selecting a user to moderate. With an option condition, you can check against the options the command executor entered.
For example, with a text option block, you can set pre-defined options for a command executor to choose from. With a option condition, you can check to see which option the command user chose.
For instance, with three preset choices, you will need three total conditions from one option condition block. For each condition, you can run unique actions based upon the option the command executor chose! For a greater understanding on how to set up an option condition, please see below.
Permissions condition checks to see if the current, or if a selected, user has a permission, e.g. if they have the administrator permission. This can be useful for staff-only buttons, whereby you can make sure that the interacting user has the permissions required.
Remember, to refer to the interacting user you can use {interaction[user.id]}
. Otherwise, you can enter any user ID when creating a permission condition. To check for multiple permissions, e.g., if the user has manage roles or kick member permissions, you can make multiple conditions.
To check if a user has manage roles and kick member permissions for example, you must use multiple permissions condition blocks; one after the other. See the example below to see how.
Instead of checking permissions, why not check if a user has a role? By using a role condition block, you can check if a user has a staff role for example or not! This can be useful for ensuring only users with a set role can use components or commands.
Like the permissions condition, with each condition you make in a singular role condition block, this will check if the user has any of the roles listed. To check if a user has one or more roles, you will need to use multiple role condition blocks, one after the other. For example:
User conditions allow you to check if the interacting user is someone specific. This can be useful for developer-only commands, whereby you check to see if the command executor is a developer. To set up a user condition, just enter the user IDs you wish to perform unique actions with.
For instance, you can have unique actions run depending on who the interacting user is. Else, other actions can be run for users who are not listed in the user condition. See below for an example.