Class RatelimitAttribute
Sets how often a user is allowed to use this command or any command in this module.
Inherited Members
Namespace: Discord.Addons.Preconditions
Assembly: Discord.Addons.Preconditions.dll
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class RatelimitAttribute : PreconditionAttribute
Remarks
warning
This is backed by an in-memory collection and will not persist with restarts.
Constructors
| Improve this Doc View SourceRatelimitAttribute(UInt32, Double, Measure, RatelimitFlags)
Sets how often a user is allowed to use this command.
Declaration
public RatelimitAttribute(uint times, double period, Measure measure, RatelimitFlags flags = RatelimitFlags.None)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt32 | times | The number of times a user may use the command within a certain period. |
| Double | period | The amount of time since first invoke a user has until the limit is lifted. |
| Measure | measure | The scale in which the |
| RatelimitFlags | flags | Flags to set behavior of the ratelimit. |
RatelimitAttribute(UInt32, TimeSpan, RatelimitFlags)
Sets how often a user is allowed to use this command.
Declaration
public RatelimitAttribute(uint times, TimeSpan period, RatelimitFlags flags = RatelimitFlags.None)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt32 | times | The number of times a user may use the command within a certain period. |
| TimeSpan | period | The amount of time since first invoke a user has until the limit is lifted. |
| RatelimitFlags | flags | Flags to set bahavior of the ratelimit. |
Remarks
warning
This is a convinience constructor overload for use with the dynamic command builders, but not with the Class & Method-style commands.
Properties
| Improve this Doc View SourceErrorMessage
Declaration
public override string ErrorMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Overrides
Methods
| Improve this Doc View SourceCheckPermissionsAsync(ICommandContext, CommandInfo, IServiceProvider)
Declaration
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo _, IServiceProvider __)
Parameters
| Type | Name | Description |
|---|---|---|
| ICommandContext | context | |
| CommandInfo | _ | |
| IServiceProvider | __ |
Returns
| Type | Description |
|---|---|
| Task<PreconditionResult> |