This commit is contained in:
Stanley Dimant
2025-01-05 02:27:43 +01:00
parent f047435ad9
commit 9760c11e42
2 changed files with 24 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ using Discord;
using MareSynchronosShared.Utils;
using MareSynchronosShared.Utils.Configuration;
using Discord.WebSocket;
using Microsoft.EntityFrameworkCore;
namespace MareSynchronosServices.Discord;
@@ -89,7 +90,8 @@ public partial class MareWizardModule
var maxGroupsByUser = _mareClientConfigurationService.GetValueOrDefault(nameof(ServerConfiguration.MaxGroupUserCount), 3);
using var db = await GetDbContext().ConfigureAwait(false);
var user = db.Users.Single(u => u.UID == uid);
var user = await db.Users.SingleAsync(u => u.UID == uid).ConfigureAwait(false);
var lodestone = await db.Users.SingleOrDefaultAsync(u => u.UID == uid).ConfigureAwait(false);
await SharedDbFunctions.PurgeUser(_logger, user, db, maxGroupsByUser).ConfigureAwait(false);
EmbedBuilder eb = new();
@@ -102,7 +104,11 @@ public partial class MareWizardModule
await _botServices.LogToChannel($"{Context.User.Mention} DELETE SUCCESS: {uid}").ConfigureAwait(false);
await _botServices.RemoveRegisteredRoleAsync(Context.Interaction.User).ConfigureAwait(false);
// only remove role if deleted uid has lodestone attached (== primary uid)
if (lodestone != null)
{
await _botServices.RemoveRegisteredRoleAsync(Context.Interaction.User).ConfigureAwait(false);
}
}
}
catch (Exception ex)