Class GuildRateLimitAttribute
Specifies a rate limit for a interaction request or command group for the whole guild.
Inheritance
Inherited Members
Namespace: Color_Chan.Discord.Commands.Attributes.ProvidedRequirements
Assembly: Color-Chan.Discord.Commands.dll
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class GuildRateLimitAttribute : BaseRateLimitAttribute
Remarks
This requirement will limit the amount of time all the users in a guild can request a interaction during a time period.
Examples
This example limits all the interactions in the PongCommands slash command module to 2 requests every 10 seconds and 4 requests every 30 seconds for the whole guild. You can also put the GuildRateLimitAttribute on a method if you only want to rate limit a specific interaction.
[GuildRateLimit(2, 10)]
[GuildRateLimit(4, 30)]
public class PongCommands : SlashCommandModule
{
[SlashCommand("ping", "Ping Pong!")]
public Task<IDiscordInteractionResponse> PongAsync()
{
// Command code...
}
}
Constructors
| Improve this Doc View SourceGuildRateLimitAttribute(Int32, Int32)
Initializes a new instance of GuildRateLimitAttribute.
Declaration
public GuildRateLimitAttribute(int max, int resetAfterSeconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | max | The max amount of time the command could be used during the time period. |
Int32 | resetAfterSeconds | The timeframe in which the command can be used a certain amount of times. |
Methods
| Improve this Doc View SourceCheckRequirementAsync(IInteractionContext, IServiceProvider)
Checks if a specific requirement for a interaction request has met.
Declaration
public override async Task<Result> CheckRequirementAsync(IInteractionContext context, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | The IInteractionContext of the interaction request. |
System.IServiceProvider | services | The System.IServiceProvider containing all the necessary dependencies for the interaction request. |
Returns
Type | Description |
---|---|
Task<Result> | The result of the interaction request requirement. |