using DSharpPlus; namespace X10D.DSharpPlus; /// /// Extension methods for . /// public static class DiscordClientExtensions { /// /// Instructs the client to automatically join all existing threads, and any newly-created threads. /// /// The whose events should be subscribed. /// /// to automatically rejoin a thread if this client was removed; otherwise, /// . /// public static void AutoJoinThreads(this DiscordClient client, bool rejoinIfRemoved = true) { client.GuildAvailable += (_, args) => args.Guild.JoinAllThreadsAsync(); client.ThreadCreated += (_, args) => args.Thread.JoinThreadAsync(); if (rejoinIfRemoved) { client.ThreadMembersUpdated += (_, args) => { if (args.RemovedMembers.Any(m => m.Id == client.CurrentUser.Id)) return args.Thread.JoinThreadAsync(); return Task.CompletedTask; }; } } }