feat: store system UUIDs of banned users per guild
This commit is contained in:
parent
5ac607fd0a
commit
5f24a6aa88
9 changed files with 121 additions and 18 deletions
|
|
@ -76,7 +76,12 @@ public class GuildBanAddResponder(
|
|||
evt.GuildID
|
||||
);
|
||||
|
||||
await guildRepository.BanSystemAsync(evt.GuildID, pkSystem.Id, pkSystem.Uuid);
|
||||
await guildRepository.BanSystemAsync(
|
||||
evt.GuildID,
|
||||
evt.User.ID,
|
||||
pkSystem.Id,
|
||||
pkSystem.Uuid
|
||||
);
|
||||
}
|
||||
|
||||
embed.AddField(
|
||||
|
|
|
|||
|
|
@ -67,20 +67,52 @@ public class GuildBanRemoveResponder(
|
|||
var pkSystem = await pluralkitApi.GetPluralKitSystemAsync(evt.User.ID.Value, ct);
|
||||
if (pkSystem != null)
|
||||
{
|
||||
await guildRepository.UnbanSystemAsync(evt.GuildID, pkSystem.Id, pkSystem.Uuid);
|
||||
|
||||
embed.AddField(
|
||||
"PluralKit system",
|
||||
$"""
|
||||
**ID:** {pkSystem.Id}
|
||||
**UUID:** `{pkSystem.Uuid}`
|
||||
**Name:** {pkSystem.Name ?? "*(none)*"}
|
||||
**Tag:** {pkSystem.Tag ?? "*(none)*"}
|
||||
|
||||
This system has been unbanned.
|
||||
Note that other accounts linked to the system might still be banned, check `pk;system {pkSystem.Id}` for the linked accounts.
|
||||
"""
|
||||
await guildRepository.UnbanSystemAsync(
|
||||
evt.GuildID,
|
||||
evt.User.ID,
|
||||
pkSystem.Id,
|
||||
pkSystem.Uuid
|
||||
);
|
||||
|
||||
var systemUsers = await guildRepository.GetSystemAccountsAsync(
|
||||
evt.GuildID,
|
||||
pkSystem.Uuid
|
||||
);
|
||||
if (systemUsers.Length == 0)
|
||||
{
|
||||
embed.AddField(
|
||||
"PluralKit system",
|
||||
$"""
|
||||
**ID:** {pkSystem.Id}
|
||||
**UUID:** `{pkSystem.Uuid}`
|
||||
**Name:** {pkSystem.Name ?? "*(none)*"}
|
||||
**Tag:** {pkSystem.Tag ?? "*(none)*"}
|
||||
|
||||
This system has been unbanned.
|
||||
Note that other accounts linked to the system might still be banned, check `pk;system {pkSystem.Id}` for the linked accounts.
|
||||
"""
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
var users = new List<string>();
|
||||
foreach (var id in systemUsers)
|
||||
users.Add("- " + await userCache.TryFormatUserAsync(id));
|
||||
|
||||
embed.AddField(
|
||||
"PluralKit system",
|
||||
$"""
|
||||
**ID:** {pkSystem.Id}
|
||||
**UUID:** `{pkSystem.Uuid}`
|
||||
**Name:** {pkSystem.Name ?? "*(none)*"}
|
||||
**Tag:** {pkSystem.Tag ?? "*(none)*"}
|
||||
|
||||
This system has been unbanned.
|
||||
Note that the following accounts are known to be linked to this system and banned from this server:
|
||||
{string.Join("\n", users)}
|
||||
"""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
webhookExecutor.QueueLog(
|
||||
|
|
|
|||
|
|
@ -107,14 +107,14 @@ public class GuildCreateResponder(
|
|||
}
|
||||
|
||||
// Clear the cache for this guild
|
||||
guildCache.Remove(evt.ID, out _);
|
||||
var wasCached = guildCache.Remove(evt.ID, out var guild);
|
||||
emojiCache.Remove(evt.ID);
|
||||
channelCache.RemoveGuild(evt.ID);
|
||||
roleCache.RemoveGuild(evt.ID);
|
||||
await memberCache.RemoveAllMembersAsync(evt.ID);
|
||||
await inviteCache.RemoveAsync(evt.ID);
|
||||
|
||||
if (!guildCache.TryGet(evt.ID, out var guild))
|
||||
if (!wasCached || guild == null)
|
||||
{
|
||||
_logger.Information("Left uncached guild {GuildId}", evt.ID);
|
||||
return Result.Success;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue