Fixed nullref in cmdcd

This commit is contained in:
Kwoth
2022-11-08 07:45:46 +01:00
parent 780a260b88
commit 8f0c5fab47

View File

@@ -29,8 +29,11 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService
public Task<bool> ExecPreCommandAsync(ICommandContext context, string moduleName, CommandInfo command) public Task<bool> ExecPreCommandAsync(ICommandContext context, string moduleName, CommandInfo command)
=> TryBlock(context.Guild, context.User, command.Name.ToLowerInvariant()); => TryBlock(context.Guild, context.User, command.Name.ToLowerInvariant());
public Task<bool> TryBlock(IGuild guild, IUser user, string commandName) public Task<bool> TryBlock(IGuild? guild, IUser user, string commandName)
{ {
if (guild is null)
return Task.FromResult(false);
if (!_settings.TryGetValue(guild.Id, out var cooldownSettings)) if (!_settings.TryGetValue(guild.Id, out var cooldownSettings))
return Task.FromResult(false); return Task.FromResult(false);