Added new rules concerning type constraints and :base() calls. Reformatted attributes folder

This commit is contained in:
Kwoth
2021-12-26 17:45:26 +01:00
parent d5fd6aae8e
commit 9ae030a5c5
10 changed files with 39 additions and 21 deletions

View File

@@ -15,7 +15,10 @@ public sealed class RatelimitAttribute : PreconditionAttribute
Seconds = seconds;
}
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
public override Task<PreconditionResult> CheckPermissionsAsync(
ICommandContext context,
CommandInfo command,
IServiceProvider services)
{
if (Seconds == 0)
return Task.FromResult(PreconditionResult.FromSuccess());
@@ -23,7 +26,7 @@ public sealed class RatelimitAttribute : PreconditionAttribute
var cache = services.GetRequiredService<IDataCache>();
var rem = cache.TryAddRatelimit(context.User.Id, command.Name, Seconds);
if(rem is null)
if (rem is null)
return Task.FromResult(PreconditionResult.FromSuccess());
var msgContent = $"You can use this command again in {rem.Value.TotalSeconds:F1}s.";