Fixed nullref in xploop

This commit is contained in:
Kwoth
2022-11-10 22:32:27 +01:00
parent 8f0c5fab47
commit 3992ae392b
3 changed files with 16 additions and 11 deletions

View File

@@ -71,8 +71,11 @@ public sealed class GamblingTxTracker : ITxTracker, INService, IReadyExecutor
}
}
public Task TrackAdd(long amount, TxData txData)
public Task TrackAdd(long amount, TxData? txData)
{
if (txData is null)
return Task.CompletedTask;
if (_gamblingTypes.Contains(txData.Type))
{
_stats.AddOrUpdate(txData.Type,
@@ -83,8 +86,11 @@ public sealed class GamblingTxTracker : ITxTracker, INService, IReadyExecutor
return Task.CompletedTask;
}
public Task TrackRemove(long amount, TxData txData)
public Task TrackRemove(long amount, TxData? txData)
{
if (txData is null)
return Task.CompletedTask;
if (_gamblingTypes.Contains(txData.Type))
{
_stats.AddOrUpdate(txData.Type,

View File

@@ -1,6 +1,5 @@
using NadekoBot.Services.Currency;
#nullable disable
namespace NadekoBot.Services;
public interface ICurrencyService
@@ -10,32 +9,32 @@ public interface ICurrencyService
Task AddBulkAsync(
IReadOnlyCollection<ulong> userIds,
long amount,
TxData txData,
TxData? txData,
CurrencyType type = CurrencyType.Default);
Task RemoveBulkAsync(
IReadOnlyCollection<ulong> userIds,
long amount,
TxData txData,
TxData? txData,
CurrencyType type = CurrencyType.Default);
Task AddAsync(
ulong userId,
long amount,
TxData txData);
TxData? txData);
Task AddAsync(
IUser user,
long amount,
TxData txData);
TxData? txData);
Task<bool> RemoveAsync(
ulong userId,
long amount,
TxData txData);
TxData? txData);
Task<bool> RemoveAsync(
IUser user,
long amount,
TxData txData);
TxData? txData);
}

View File

@@ -4,6 +4,6 @@ namespace NadekoBot.Services;
public interface ITxTracker
{
Task TrackAdd(long amount, TxData txData);
Task TrackRemove(long amount, TxData txData);
Task TrackAdd(long amount, TxData? txData);
Task TrackRemove(long amount, TxData? txData);
}