Class Cooldown
- Namespace
- BotManager.Runtime.Expressions
- Assembly
- BotManager.Runtime.dll
Executes the Action expression with a cooldown of Milliseconds. If this expression is called multiple times while the cooldown timer is still ticking down, then the Fallback branch is executed instead.
The cooldown timer is started before Action is executed. The time Action takes to run is ignored in the cooldown timer.
Returns the value of the executed branch.
10, but when called again withing 5 minutes will return 0:
{ "$Cooldown": { "Action": 10, "Fallback": 0, "Milliseconds": 300000 } }
public sealed class Cooldown : IExpression
- Inheritance
-
Cooldown
- Implements
- Inherited Members
Constructors
Cooldown()
public Cooldown()
Properties
Action
Gets and sets the main expression to execute when no cooldown timer is ticking.
public IExpression? Action { get; set; }
Property Value
Fallback
Gets and sets the optional fallback expression that is executed when a the cooldown timer is still ticking down.
public IExpression? Fallback { get; set; }
Property Value
Milliseconds
Gets and sets the number of milliseconds for the cooldown timer.
public IExpression? Milliseconds { get; set; }
Property Value
Methods
ExecuteAsync(RuntimeContext, Type?)
Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.
public Task<object?> ExecuteAsync(RuntimeContext context, Type? returnType)
Parameters
contextRuntimeContextThe current runtime context.
returnTypeTypeThe expected return type. Use
typeof(object)for a generic result. Usenullif you don't need the return value.