feat: flesh out member remove responder
This commit is contained in:
parent
516ce3a6e9
commit
b31a20bb81
8 changed files with 119 additions and 12 deletions
|
|
@ -81,6 +81,20 @@ public static class DiscordExtensions
|
|||
if (!ctx.TryGetGuildID(out var guildId)) throw new CataloggerError("No guild ID in context");
|
||||
return (userId, guildId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sorts a list of roles by their position in the Discord interface.
|
||||
/// </summary>
|
||||
/// <param name="roles">The list of guild roles to filter.</param>
|
||||
/// <param name="filterByIds">An optional list of role IDs to return, from a member object or similar.
|
||||
/// If null, the entire list is returned.</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<IRole> Sorted(this IEnumerable<IRole> roles,
|
||||
IEnumerable<Snowflake>? filterByIds = null)
|
||||
{
|
||||
var sorted = roles.OrderByDescending(r => r.Position);
|
||||
return filterByIds != null ? sorted.Where(r => filterByIds.Contains(r.ID)) : sorted;
|
||||
}
|
||||
|
||||
public class DiscordRestException(string message) : Exception(message);
|
||||
}
|
||||
|
|
@ -73,9 +73,11 @@ public static class StartupExtensions
|
|||
.AddSingleton<RoleCache>()
|
||||
.AddSingleton<ChannelCache>()
|
||||
.AddSingleton<UserCache>()
|
||||
.AddSingleton<AuditLogCache>()
|
||||
.AddSingleton<PluralkitApiService>()
|
||||
.AddScoped<IEncryptionService, EncryptionService>()
|
||||
.AddSingleton<MetricsCollectionService>()
|
||||
.AddSingleton<AuditLogEnrichedResponderService>()
|
||||
.AddScoped<MessageRepository>()
|
||||
.AddSingleton<WebhookExecutorService>()
|
||||
.AddSingleton<PkMessageHandler>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue