feat: store system UUIDs of banned users per guild

This commit is contained in:
sam 2024-11-05 15:32:53 +01:00
parent 5ac607fd0a
commit 5f24a6aa88
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
9 changed files with 121 additions and 18 deletions

View file

@ -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(