using DSharpPlus; using DSharpPlus.Entities; namespace X10D.DSharpPlus; /// /// Extension methods for . /// public static class DiscordGuildExtensions { /// /// Joins all active threads in the guild that this client has permission to view. /// /// The guild whose active threads to join. /// is . public static async Task JoinAllThreadsAsync(this DiscordGuild guild) { #if NET6_0_OR_GREATER ArgumentNullException.ThrowIfNull(guild); #else if (guild is null) { throw new ArgumentNullException(nameof(guild)); } #endif await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())); } /// /// Normalizes a so that the internal client is assured to be a specified value. /// /// The to normalize. /// The target client. /// /// A whose public values will match , but whose internal client is /// . /// /// /// is /// -or- /// is /// public static async Task NormalizeClientAsync(this DiscordGuild guild, DiscordClient client) { #if NET6_0_OR_GREATER ArgumentNullException.ThrowIfNull(guild); ArgumentNullException.ThrowIfNull(client); #else if (guild is null) { throw new ArgumentNullException(nameof(guild)); } if (client is null) { throw new ArgumentNullException(nameof(client)); } #endif return await client.GetGuildAsync(guild.Id); } }