Another attempt to stop all the EF issues :(

This commit is contained in:
barelyprofessional
2025-10-03 18:04:50 -05:00
parent 2a0f74ab18
commit 69ea0b6b0b
3 changed files with 66 additions and 44 deletions

View File

@@ -74,7 +74,7 @@ internal class BotCommands
if (!kasinoEnabled) return;
}
if (kasinoCommand && Money.IsPermanentlyBannedAsync(user, _cancellationToken).Result)
if (kasinoCommand && Money.IsPermanentlyBannedAsync(user.Id, _cancellationToken).Result)
{
_bot.SendChatMessage($"@{message.Author.Username}, you've been permanently banned from the kasino. Contact support for more information.", true);
return;
@@ -84,13 +84,16 @@ internal class BotCommands
{
// GetGamblerEntity will only return null if the user is permanbanned
// and we have a check further up the chain for that hence ignoring the null
var gambler = Money.GetGamblerEntityAsync(user, ct: _cancellationToken).Result;
var exclusion = Money.GetActiveExclusionAsync(gambler!, ct: _cancellationToken).Result;
if (exclusion != null)
var gambler = Money.GetGamblerEntityAsync(user.Id, ct: _cancellationToken).Result;
if (gambler != null)
{
_bot.SendChatMessage(
$"@{message.Author.Username}, you're self excluded from the kasino for another {(exclusion.Expires - DateTimeOffset.UtcNow).Humanize(precision: 3)}", true);
return;
var exclusion = Money.GetActiveExclusionAsync(gambler.Id, ct: _cancellationToken).Result;
if (exclusion != null)
{
_bot.SendChatMessage(
$"@{message.Author.Username}, you're self excluded from the kasino for another {(exclusion.Expires - DateTimeOffset.UtcNow).Humanize(precision: 3)}", true);
return;
}
}
}
@@ -140,14 +143,14 @@ internal class BotCommands
if (!(await SettingsProvider.GetValueAsync(BuiltIn.Keys.MoneyEnabled)).ToBoolean()) return;
var wagerCommand = HasAttribute<WagerCommand>(command);
if (!wagerCommand) return;
var gambler = await Money.GetGamblerEntityAsync(user, ct: _cancellationToken);
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: _cancellationToken);
if (gambler == null) return;
if (gambler.TotalWagered < gambler.NextVipLevelWagerRequirement) return;
// The reason for doing this instead of passing in TotalWagered is that otherwise VIP levels might
// get skipped if the user is a low VIP level but wagering very large amounts
var newLevel = Money.GetNextVipLevel(gambler.NextVipLevelWagerRequirement);
if (newLevel == null) return;
var payout = await Money.UpgradeVipLevelAsync(gambler, newLevel, _cancellationToken);
var payout = await Money.UpgradeVipLevelAsync(gambler.Id, newLevel, _cancellationToken);
await _bot.SendChatMessageAsync(
$"🤑🤑 {user.FormatUsername()} has leveled up to to {newLevel.VipLevel.Icon} {newLevel.VipLevel.Name} Tier {newLevel.Tier} " +
$"and received a bonus of {await payout.FormatKasinoCurrencyAsync()}", true);