diff --git a/src/NadekoBot/Modules/Permissions/CommandCooldown/CmdCdService.cs b/src/NadekoBot/Modules/Permissions/CommandCooldown/CmdCdService.cs index 4c42484ed..2037bd579 100644 --- a/src/NadekoBot/Modules/Permissions/CommandCooldown/CmdCdService.cs +++ b/src/NadekoBot/Modules/Permissions/CommandCooldown/CmdCdService.cs @@ -25,13 +25,13 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService public Task ExecPreCommandAsync(ICommandContext context, string moduleName, CommandInfo command) => TryBlock(context.Guild, context.User, command.Name.ToLowerInvariant()); - public async Task TryBlock(IGuild guild, IUser user, string commandName) + public Task TryBlock(IGuild guild, IUser user, string commandName) { if (!_settings.TryGetValue(guild.Id, out var cooldownSettings)) - return false; + return Task.FromResult(false); if (!cooldownSettings.TryGetValue(commandName, out var cdSeconds)) - return false; + return Task.FromResult(false); var cooldowns = _activeCooldowns.GetOrAdd( (guild.Id, commandName), @@ -40,7 +40,7 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService // if user is not already on cooldown, add if (cooldowns.TryAdd(user.Id, DateTime.UtcNow)) { - return false; + return Task.FromResult(false); } // if there is an entry, maybe it expired. Try to check if it expired and don't fail if it did @@ -51,11 +51,11 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService if (diff.Seconds > cdSeconds) { if (cooldowns.TryUpdate(user.Id, DateTime.UtcNow, oldValue)) - return false; + return Task.FromResult(false); } } - return true; + return Task.FromResult(true); } public async Task OnReadyAsync() diff --git a/src/NadekoBot/Services/Currency/CurrencyService.cs b/src/NadekoBot/Services/Currency/CurrencyService.cs index 3c564e4fa..6266adf09 100644 --- a/src/NadekoBot/Services/Currency/CurrencyService.cs +++ b/src/NadekoBot/Services/Currency/CurrencyService.cs @@ -90,7 +90,8 @@ public sealed class CurrencyService : ICurrencyService, INService { var wallet = await GetWalletAsync(userId); var result = await wallet.Take(amount, txData); - await _txTracker.TrackRemove(amount, txData); + if(result) + await _txTracker.TrackRemove(amount, txData); return result; }