Class CooldownAttribute
Defines a cooldown for this command. This allows you to define how many times can users execute a specific command
Namespace: DSharpPlus.CommandsNext.Attributes
Assembly: cs.temp.dll.dll
Syntax
public sealed class CooldownAttribute : CheckBaseAttribute
Constructors
CooldownAttribute(Int32, Double, CooldownBucketType)
Defines a cooldown for this command. This means that users will be able to use the command a specific number of times before they have to wait to use it again.
Declaration
public CooldownAttribute(int maxUses, double resetAfter, CooldownBucketType bucketType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxUses | Number of times the command can be used before triggering a cooldown. |
System.Double | resetAfter | Number of seconds after which the cooldown is reset. |
CooldownBucketType | bucketType | Type of cooldown bucket. This allows controlling whether the bucket will be cooled down per user, guild, channel, or globally. |
Properties
BucketType
Gets the type of the cooldown bucket. This determines how cooldowns are applied.
Declaration
public CooldownBucketType BucketType { get; }
Property Value
Type | Description |
---|---|
CooldownBucketType |
MaxUses
Gets the maximum number of uses before this command triggers a cooldown for its bucket.
Declaration
public int MaxUses { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Reset
Gets the time after which the cooldown is reset.
Declaration
public TimeSpan Reset { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
ExecuteCheckAsync(CommandContext, Boolean)
Declaration
public override Task<bool> ExecuteCheckAsync(CommandContext ctx, bool help)
Parameters
Type | Name | Description |
---|---|---|
CommandContext | ctx | |
System.Boolean | help |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
Overrides
GetBucket(CommandContext)
Gets a cooldown bucket for given command context.
Declaration
public CommandCooldownBucket GetBucket(CommandContext ctx)
Parameters
Type | Name | Description |
---|---|---|
CommandContext | ctx | Command context to get cooldown bucket for. |
Returns
Type | Description |
---|---|
CommandCooldownBucket | Requested cooldown bucket, or null if one wasn't present. |
GetRemainingCooldown(CommandContext)
Calculates the cooldown remaining for given command context.
Declaration
public TimeSpan GetRemainingCooldown(CommandContext ctx)
Parameters
Type | Name | Description |
---|---|---|
CommandContext | ctx | Context for which to calculate the cooldown. |
Returns
Type | Description |
---|---|
TimeSpan | Remaining cooldown, or zero if no cooldown is active. |