fix bug
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user