diff --git a/.editorconfig b/.editorconfig
index 4b1bbb8277..323cedc03c 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -9,7 +9,7 @@ indent_style = space
# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
-indent_size = 2
+indent_size = 4
# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
@@ -105,6 +105,10 @@ dotnet_naming_symbols.async_methods.required_modifiers = async
# Don't force namespaces to match their folder names
dotnet_diagnostic.IDE0130.severity = none
+dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+tab_width = 4
+end_of_line = crlf
###############################
# C# Coding Conventions #
@@ -180,3 +184,8 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
+csharp_using_directive_placement = inside_namespace:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_expression_bodied_local_functions = false:warning
diff --git a/DSharpPlus.Rest/DiscordRestClient.cs b/DSharpPlus.Rest/DiscordRestClient.cs
index cec17bd1ab..c12b9fbea2 100644
--- a/DSharpPlus.Rest/DiscordRestClient.cs
+++ b/DSharpPlus.Rest/DiscordRestClient.cs
@@ -3,2264 +3,2264 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
using DSharpPlus.Net.Abstractions;
using DSharpPlus.Net.Models;
-namespace DSharpPlus
+namespace DSharpPlus;
+
+public class DiscordRestClient : BaseDiscordClient
{
- public class DiscordRestClient : BaseDiscordClient
- {
- ///
- /// Gets the dictionary of guilds cached by this client.
- ///
- public override IReadOnlyDictionary Guilds
- => this._guilds_lazy.Value;
+ ///
+ /// Gets the dictionary of guilds cached by this client.
+ ///
+ public override IReadOnlyDictionary Guilds
+ => this._guilds_lazy.Value;
- internal Dictionary _guilds = new();
- private Lazy> _guilds_lazy;
+ internal Dictionary _guilds = new();
+ private Lazy> _guilds_lazy;
- public DiscordRestClient(DiscordConfiguration config) : base(config)
- {
- this._disposed = false;
- }
+ public DiscordRestClient(DiscordConfiguration config) : base(config)
+ {
+ this._disposed = false;
+ }
- ///
- /// Initializes cache
- ///
- ///
- public async Task InitializeCacheAsync()
+ ///
+ /// Initializes cache
+ ///
+ ///
+ public async Task InitializeCacheAsync()
+ {
+ await base.InitializeAsync();
+ this._guilds_lazy = new Lazy>(() => new ReadOnlyDictionary(this._guilds));
+ var gs = await this.ApiClient.GetCurrentUserGuildsAsync(100, null, null);
+ foreach (var g in gs)
{
- await base.InitializeAsync();
- this._guilds_lazy = new Lazy>(() => new ReadOnlyDictionary(this._guilds));
- var gs = await this.ApiClient.GetCurrentUserGuildsAsync(100, null, null);
- foreach (var g in gs)
- {
- this._guilds[g.Id] = g;
- }
+ this._guilds[g.Id] = g;
}
+ }
- #region Scheduled Guild Events
-
- ///
- /// Creates a new scheduled guild event.
- ///
- /// The guild to create an event on.
- /// The name of the event, up to 100 characters.
- /// The description of the event, up to 1000 characters.
- /// The channel the event will take place in, if applicable.
- /// The type of event. If , a end time must be specified.
- /// The privacy level of the event.
- /// When the event starts. Must be in the future and before the end date, if specified.
- /// When the event ends. Required for
- /// Where this location takes place.
- /// The created event.
- public Task CreateScheduledGuildEventAsync(ulong guildId, string name, string description, ulong? channelId, ScheduledGuildEventType type, ScheduledGuildEventPrivacyLevel privacyLevel, DateTimeOffset start, DateTimeOffset? end, string location = null)
- => this.ApiClient.CreateScheduledGuildEventAsync(guildId, name, description, channelId, start, end, type, privacyLevel, new DiscordScheduledGuildEventMetadata(location));
-
- ///
- /// Delete a scheduled guild event.
- ///
- /// The ID the guild the event resides on.
- /// The ID of the event to delete.
- public Task DeleteScheduledGuildEventAsync(ulong guildId, ulong eventId)
- => this.ApiClient.DeleteScheduledGuildEventAsync(guildId, eventId);
-
- ///
- /// Gets a specific scheduled guild event.
- ///
- /// The ID of the guild the event resides on.
- /// The ID of the event to get
- /// The requested event.
- public Task GetScheduledGuildEventAsync(ulong guildId, ulong eventId)
- => this.ApiClient.GetScheduledGuildEventAsync(guildId, eventId);
-
- ///
- /// Gets all available scheduled guild events.
- ///
- /// The ID of the guild to query.
- /// All active and scheduled events.
- public Task> GetScheduledGuildEventsAsync(ulong guildId)
- => this.ApiClient.GetScheduledGuildEventsAsync(guildId);
-
-
- ///
- /// Modify a scheduled guild event.
- ///
- /// The ID of the guild the event resides on.
- /// The ID of the event to modify.
- /// The action to apply to the event.
- /// The modified event.
- public Task ModifyScheduledGuildEventAsync(ulong guildId, ulong eventId, Action mdl)
+ #region Scheduled Guild Events
+
+ ///
+ /// Creates a new scheduled guild event.
+ ///
+ /// The guild to create an event on.
+ /// The name of the event, up to 100 characters.
+ /// The description of the event, up to 1000 characters.
+ /// The channel the event will take place in, if applicable.
+ /// The type of event. If , a end time must be specified.
+ /// The privacy level of the event.
+ /// When the event starts. Must be in the future and before the end date, if specified.
+ /// When the event ends. Required for
+ /// Where this location takes place.
+ /// The created event.
+ public async Task CreateScheduledGuildEventAsync(ulong guildId, string name, string description, ulong? channelId, ScheduledGuildEventType type, ScheduledGuildEventPrivacyLevel privacyLevel, DateTimeOffset start, DateTimeOffset? end, string location = null)
+ => await this.ApiClient.CreateScheduledGuildEventAsync(guildId, name, description, start, type, privacyLevel, new DiscordScheduledGuildEventMetadata(location), end, channelId);
+
+ ///
+ /// Delete a scheduled guild event.
+ ///
+ /// The ID the guild the event resides on.
+ /// The ID of the event to delete.
+ public async Task DeleteScheduledGuildEventAsync(ulong guildId, ulong eventId)
+ => await this.ApiClient.DeleteScheduledGuildEventAsync(guildId, eventId);
+
+ ///
+ /// Gets a specific scheduled guild event.
+ ///
+ /// The ID of the guild the event resides on.
+ /// The ID of the event to get
+ /// The requested event.
+ public async Task GetScheduledGuildEventAsync(ulong guildId, ulong eventId)
+ => await this.ApiClient.GetScheduledGuildEventAsync(guildId, eventId);
+
+ ///
+ /// Gets all available scheduled guild events.
+ ///
+ /// The ID of the guild to query.
+ /// All active and scheduled events.
+ public async Task> GetScheduledGuildEventsAsync(ulong guildId)
+ => await this.ApiClient.GetScheduledGuildEventsAsync(guildId);
+
+
+ ///
+ /// Modify a scheduled guild event.
+ ///
+ /// The ID of the guild the event resides on.
+ /// The ID of the event to modify.
+ /// The action to apply to the event.
+ /// The modified event.
+ public async Task ModifyScheduledGuildEventAsync(ulong guildId, ulong eventId, Action mdl)
+ {
+ var model = new ScheduledGuildEventEditModel();
+ mdl(model);
+
+ if (model.Type.HasValue && model.Type.Value is ScheduledGuildEventType.StageInstance or ScheduledGuildEventType.VoiceChannel)
+ if (!model.Channel.HasValue)
+ throw new ArgumentException("Channel must be supplied if the event is a stage instance or voice channel event.");
+
+ if (model.Type.HasValue && model.Type.Value is ScheduledGuildEventType.External)
{
- var model = new ScheduledGuildEventEditModel();
- mdl(model);
+ if (!model.EndTime.HasValue)
+ throw new ArgumentException("End must be supplied if the event is an external event.");
- if (model.Type.HasValue && model.Type.Value is ScheduledGuildEventType.StageInstance or ScheduledGuildEventType.VoiceChannel)
- if (!model.Channel.HasValue)
- throw new ArgumentException("Channel must be supplied if the event is a stage instance or voice channel event.");
+ if (!model.Metadata.HasValue || string.IsNullOrEmpty(model.Metadata.Value.Location))
+ throw new ArgumentException("Location must be supplied if the event is an external event.");
- if (model.Type.HasValue && model.Type.Value is ScheduledGuildEventType.External)
- {
- if (!model.EndTime.HasValue)
- throw new ArgumentException("End must be supplied if the event is an external event.");
+ if (model.Channel.HasValue && model.Channel.Value != null)
+ throw new ArgumentException("Channel must not be supplied if the event is an external event.");
+ }
- if (!model.Metadata.HasValue || string.IsNullOrEmpty(model.Metadata.Value.Location))
- throw new ArgumentException("Location must be supplied if the event is an external event.");
+ // We only have an ID to work off of, so we have no validation as to the current state of the event.
+ if (model.Status.HasValue && model.Status.Value is ScheduledGuildEventStatus.Scheduled)
+ throw new ArgumentException("Status cannot be set to scheduled.");
+
+ return await this.ApiClient.ModifyScheduledGuildEventAsync(
+ guildId, eventId,
+ model.Name, model.Description,
+ model.Channel.IfPresent(c => c?.Id),
+ model.StartTime, model.EndTime,
+ model.Type, model.PrivacyLevel,
+ model.Metadata, model.Status);
+ }
- if (model.Channel.HasValue && model.Channel.Value != null)
- throw new ArgumentException("Channel must not be supplied if the event is an external event.");
- }
+ ///
+ /// Gets the users interested in the guild event.
+ ///
+ /// The ID of the guild the event resides on.
+ /// The ID of the event.
+ /// How many users to query.
+ /// Fetch users after this ID.
+ /// Fetch users before this ID.
+ /// The users interested in the event.
+ public async Task> GetScheduledGuildEventUsersAsync(ulong guildId, ulong eventId, int limit = 100, ulong? after = null, ulong? before = null)
+ {
+ var remaining = limit;
+ ulong? last = null;
+ var isAfter = after != null;
- // We only have an ID to work off of, so we have no validation as to the current state of the event.
- if (model.Status.HasValue && model.Status.Value is ScheduledGuildEventStatus.Scheduled)
- throw new ArgumentException("Status cannot be set to scheduled.");
-
- return this.ApiClient.ModifyScheduledGuildEventAsync(
- guildId, eventId,
- model.Name, model.Description,
- model.Channel.IfPresent(c => c?.Id),
- model.StartTime, model.EndTime,
- model.Type, model.PrivacyLevel,
- model.Metadata, model.Status);
- }
+ var users = new List();
- ///
- /// Gets the users interested in the guild event.
- ///
- /// The ID of the guild the event resides on.
- /// The ID of the event.
- /// How many users to query.
- /// Fetch users after this ID.
- /// Fetch users before this ID.
- /// The users interested in the event.
- public async Task> GetScheduledGuildEventUsersAsync(ulong guildId, ulong eventId, int limit = 100, ulong? after = null, ulong? before = null)
+ int lastCount;
+ do
{
- var remaining = limit;
- ulong? last = null;
- var isAfter = after != null;
+ var fetchSize = remaining > 100 ? 100 : remaining;
+ var fetch = await this.ApiClient.GetScheduledGuildEventUsersAsync(guildId, eventId, true, fetchSize, !isAfter ? last ?? before : null, isAfter ? last ?? after : null);
- var users = new List();
+ lastCount = fetch.Count;
+ remaining -= lastCount;
- int lastCount;
- do
+ if (!isAfter)
{
- var fetchSize = remaining > 100 ? 100 : remaining;
- var fetch = await this.ApiClient.GetScheduledGuildEventUsersAsync(guildId, eventId, true, fetchSize, !isAfter ? last ?? before : null, isAfter ? last ?? after : null);
-
- lastCount = fetch.Count;
- remaining -= lastCount;
-
- if (!isAfter)
- {
- users.AddRange(fetch);
- last = fetch.LastOrDefault()?.Id;
- }
- else
- {
- users.InsertRange(0, fetch);
- last = fetch.FirstOrDefault()?.Id;
- }
+ users.AddRange(fetch);
+ last = fetch.LastOrDefault()?.Id;
}
- while (remaining > 0 && lastCount > 0);
+ else
+ {
+ users.InsertRange(0, fetch);
+ last = fetch.FirstOrDefault()?.Id;
+ }
+ }
+ while (remaining > 0 && lastCount > 0);
- return users.AsReadOnly();
- }
+ return users.AsReadOnly();
+ }
- #endregion
-
- #region Guild
-
- ///
- /// Searches the given guild for members who's display name start with the specified name.
- ///
- /// The ID of the guild to search.
- /// The name to search for.
- /// The maximum amount of members to return. Max 1000. Defaults to 1.
- /// The members found, if any.
- public Task> SearchMembersAsync(ulong guild_id, string name, int? limit = 1)
- => this.ApiClient.SearchMembersAsync(guild_id, name, limit);
-
- ///
- /// Creates a new guild
- ///
- /// New guild's name
- /// New guild's region ID
- /// New guild's icon (base64)
- /// New guild's verification level
- /// New guild's default message notification level
- /// New guild's system channel flags
- ///
- public Task CreateGuildAsync(string name, string region_id, string iconb64, VerificationLevel? verification_level, DefaultMessageNotifications? default_message_notifications, SystemChannelFlags? system_channel_flags)
- => this.ApiClient.CreateGuildAsync(name, region_id, iconb64, verification_level, default_message_notifications, system_channel_flags);
-
- ///
- /// Creates a guild from a template. This requires the bot to be in less than 10 guilds total.
- ///
- /// The template code.
- /// Name of the guild.
- /// Stream containing the icon for the guild.
- /// The created guild.
- public Task CreateGuildFromTemplateAsync(string code, string name, string icon)
- => this.ApiClient.CreateGuildFromTemplateAsync(code, name, icon);
-
- ///
- /// Deletes a guild
- ///
- /// Guild ID
- ///
- public Task DeleteGuildAsync(ulong id)
- => this.ApiClient.DeleteGuildAsync(id);
-
- ///
- /// Modifies a guild
- ///
- /// Guild ID
- /// New guild Name
- /// New guild voice region
- /// New guild verification level
- /// New guild default message notification level
- /// New guild MFA level
- /// New guild explicit content filter level
- /// New guild AFK channel ID
- /// New guild AFK timeout in seconds
- /// New guild icon (base64)
- /// New guild owner ID
- /// New guild splash (base64)
- /// New guild system channel ID
- /// New guild banner
- /// New guild description
- /// New guild Discovery splash
- /// List of new guild features
- /// New preferred locale
- /// New updates channel ID
- /// New rules channel ID
- /// New system channel flags
- /// Modify reason
- ///
- public Task ModifyGuildAsync(ulong guild_id, Optional name,
- Optional region, Optional verification_level,
- Optional default_message_notifications, Optional mfa_level,
- Optional explicit_content_filter, Optional afk_channel_id,
- Optional afk_timeout, Optional iconb64, Optional owner_id, Optional splashb64,
- Optional systemChannelId, Optional banner, Optional description,
- Optional discorverySplash, Optional> features, Optional preferredLocale,
- Optional publicUpdatesChannelId, Optional rulesChannelId, Optional systemChannelFlags,
- string reason)
- => this.ApiClient.ModifyGuildAsync(guild_id, name, region, verification_level, default_message_notifications, mfa_level, explicit_content_filter, afk_channel_id, afk_timeout, iconb64,
- owner_id, splashb64, systemChannelId, banner, description, discorverySplash, features, preferredLocale, publicUpdatesChannelId, rulesChannelId, systemChannelFlags, reason);
-
- ///
- /// Modifies a guild
- ///
- /// Guild ID
- /// Guild modifications
- ///
- public async Task ModifyGuildAsync(ulong guild_id, Action action)
- {
- var mdl = new GuildEditModel();
- action(mdl);
-
- if (mdl.AfkChannel.HasValue)
- if (mdl.AfkChannel.Value.Type != ChannelType.Voice)
- throw new ArgumentException("AFK channel needs to be a voice channel!");
-
- var iconb64 = Optional.FromNoValue();
- if (mdl.Icon.HasValue && mdl.Icon.Value != null)
- using (var imgtool = new ImageTool(mdl.Icon.Value))
- iconb64 = imgtool.GetBase64();
- else if (mdl.Icon.HasValue)
- iconb64 = null;
-
- var splashb64 = Optional.FromNoValue();
- if (mdl.Splash.HasValue && mdl.Splash.Value != null)
- using (var imgtool = new ImageTool(mdl.Splash.Value))
- splashb64 = imgtool.GetBase64();
- else if (mdl.Splash.HasValue)
- splashb64 = null;
-
- var bannerb64 = Optional.FromNoValue();
-
- if (mdl.Banner.HasValue && mdl.Banner.Value != null)
- using (var imgtool = new ImageTool(mdl.Banner.Value))
- bannerb64 = imgtool.GetBase64();
- else if (mdl.Banner.HasValue)
- bannerb64 = null;
-
- return await this.ApiClient.ModifyGuildAsync(guild_id, mdl.Name, mdl.Region.IfPresent(x => x.Id), mdl.VerificationLevel, mdl.DefaultMessageNotifications,
- mdl.MfaLevel, mdl.ExplicitContentFilter, mdl.AfkChannel.IfPresent(x => x?.Id), mdl.AfkTimeout, iconb64, mdl.Owner.IfPresent(x => x.Id),
- splashb64, mdl.SystemChannel.IfPresent(x => x?.Id), bannerb64, mdl.Description, mdl.DiscoverySplash, mdl.Features, mdl.PreferredLocale,
- mdl.PublicUpdatesChannel.IfPresent(e => e?.Id), mdl.RulesChannel.IfPresent(e => e?.Id), mdl.SystemChannelFlags, mdl.AuditLogReason);
- }
+ #endregion
+
+ #region Guild
+
+ ///
+ /// Searches the given guild for members who's display name start with the specified name.
+ ///
+ /// The ID of the guild to search.
+ /// The name to search for.
+ /// The maximum amount of members to return. Max 1000. Defaults to 1.
+ /// The members found, if any.
+ public async Task> SearchMembersAsync(ulong guild_id, string name, int? limit = 1)
+ => await this.ApiClient.SearchMembersAsync(guild_id, name, limit);
+
+ ///
+ /// Creates a new guild
+ ///
+ /// New guild's name
+ /// New guild's region ID
+ /// New guild's icon (base64)
+ /// New guild's verification level
+ /// New guild's default message notification level
+ /// New guild's system channel flags
+ ///
+ public async Task CreateGuildAsync(string name, string region_id, string iconb64, VerificationLevel? verification_level, DefaultMessageNotifications? default_message_notifications, SystemChannelFlags? system_channel_flags)
+ => await this.ApiClient.CreateGuildAsync(name, region_id, iconb64, verification_level, default_message_notifications, system_channel_flags);
+
+ ///
+ /// Creates a guild from a template. This requires the bot to be in less than 10 guilds total.
+ ///
+ /// The template code.
+ /// Name of the guild.
+ /// Stream containing the icon for the guild.
+ /// The created guild.
+ public async Task CreateGuildFromTemplateAsync(string code, string name, string icon)
+ => await this.ApiClient.CreateGuildFromTemplateAsync(code, name, icon);
+
+ ///
+ /// Deletes a guild
+ ///
+ /// Guild ID
+ ///
+ public async Task DeleteGuildAsync(ulong id)
+ => await this.ApiClient.DeleteGuildAsync(id);
+
+ ///
+ /// Modifies a guild
+ ///
+ /// Guild ID
+ /// New guild Name
+ /// New guild voice region
+ /// New guild verification level
+ /// New guild default message notification level
+ /// New guild MFA level
+ /// New guild explicit content filter level
+ /// New guild AFK channel ID
+ /// New guild AFK timeout in seconds
+ /// New guild icon (base64)
+ /// New guild owner ID
+ /// New guild splash (base64)
+ /// New guild system channel ID
+ /// New guild banner
+ /// New guild description
+ /// New guild Discovery splash
+ /// List of new guild features
+ /// New preferred locale
+ /// New updates channel ID
+ /// New rules channel ID
+ /// New system channel flags
+ /// Modify reason
+ ///
+ public async Task ModifyGuildAsync(ulong guild_id, Optional name,
+ Optional region, Optional verification_level,
+ Optional default_message_notifications, Optional mfa_level,
+ Optional explicit_content_filter, Optional afk_channel_id,
+ Optional afk_timeout, Optional iconb64, Optional owner_id, Optional splashb64,
+ Optional systemChannelId, Optional banner, Optional description,
+ Optional discorverySplash, Optional> features, Optional preferredLocale,
+ Optional publicUpdatesChannelId, Optional rulesChannelId, Optional systemChannelFlags,
+ string reason)
+ => await this.ApiClient.ModifyGuildAsync(guild_id, name, region, verification_level, default_message_notifications, mfa_level, explicit_content_filter, afk_channel_id, afk_timeout, iconb64,
+ owner_id, splashb64, systemChannelId, banner, description, discorverySplash, features, preferredLocale, publicUpdatesChannelId, rulesChannelId, systemChannelFlags, reason);
+
+ ///
+ /// Modifies a guild
+ ///
+ /// Guild ID
+ /// Guild modifications
+ ///
+ public async Task ModifyGuildAsync(ulong guild_id, Action action)
+ {
+ var mdl = new GuildEditModel();
+ action(mdl);
+
+ if (mdl.AfkChannel.HasValue)
+ if (mdl.AfkChannel.Value.Type != ChannelType.Voice)
+ throw new ArgumentException("AFK channel needs to be a voice channel!");
+
+ var iconb64 = Optional.FromNoValue();
+ if (mdl.Icon.HasValue && mdl.Icon.Value != null)
+ using (var imgtool = new ImageTool(mdl.Icon.Value))
+ iconb64 = imgtool.GetBase64();
+ else if (mdl.Icon.HasValue)
+ iconb64 = null;
+
+ var splashb64 = Optional.FromNoValue();
+ if (mdl.Splash.HasValue && mdl.Splash.Value != null)
+ using (var imgtool = new ImageTool(mdl.Splash.Value))
+ splashb64 = imgtool.GetBase64();
+ else if (mdl.Splash.HasValue)
+ splashb64 = null;
+
+ var bannerb64 = Optional.FromNoValue();
+
+ if (mdl.Banner.HasValue && mdl.Banner.Value != null)
+ using (var imgtool = new ImageTool(mdl.Banner.Value))
+ bannerb64 = imgtool.GetBase64();
+ else if (mdl.Banner.HasValue)
+ bannerb64 = null;
+
+ return await this.ApiClient.ModifyGuildAsync(guild_id, mdl.Name, mdl.Region.IfPresent(x => x.Id), mdl.VerificationLevel, mdl.DefaultMessageNotifications,
+ mdl.MfaLevel, mdl.ExplicitContentFilter, mdl.AfkChannel.IfPresent(x => x?.Id), mdl.AfkTimeout, iconb64, mdl.Owner.IfPresent(x => x.Id),
+ splashb64, mdl.SystemChannel.IfPresent(x => x?.Id), bannerb64, mdl.Description, mdl.DiscoverySplash, mdl.Features, mdl.PreferredLocale,
+ mdl.PublicUpdatesChannel.IfPresent(e => e?.Id), mdl.RulesChannel.IfPresent(e => e?.Id), mdl.SystemChannelFlags, mdl.AuditLogReason);
+ }
- ///
- /// Gets guild bans.
- ///
- /// The ID of the guild to get the bans from.
- /// The number of users to return (up to maximum 1000, default 1000).
- /// Consider only users before the given user ID.
- /// Consider only users after the given user ID.
- /// A collection of the guild's bans.
- public Task> GetGuildBansAsync(ulong guild_id, int? limit = null, ulong? before = null, ulong? after = null)
- => this.ApiClient.GetGuildBansAsync(guild_id, limit, before, after);
-
- ///
- /// Gets the ban of the specified user. Requires Ban Members permission.
- ///
- /// The ID of the guild to get the ban from.
- /// The ID of the user to get the ban for.
- /// A guild ban object.
- public Task GetGuildBanAsync(ulong guild_id, ulong user_id)
- => this.ApiClient.GetGuildBanAsync(guild_id, user_id);
-
- ///
- /// Creates guild ban
- ///
- /// Guild ID
- /// User ID
- /// Days to delete messages
- /// Reason why this member was banned
- ///
- public Task CreateGuildBanAsync(ulong guild_id, ulong user_id, int delete_message_days, string reason)
- => this.ApiClient.CreateGuildBanAsync(guild_id, user_id, delete_message_days, reason);
-
- ///
- /// Removes a guild ban
- ///
- /// Guild ID
- /// User to unban
- /// Reason why this member was unbanned
- ///
- public Task RemoveGuildBanAsync(ulong guild_id, ulong user_id, string reason)
- => this.ApiClient.RemoveGuildBanAsync(guild_id, user_id, reason);
-
- ///
- /// Leaves a guild
- ///
- /// Guild ID
- ///
- public Task LeaveGuildAsync(ulong guild_id)
- => this.ApiClient.LeaveGuildAsync(guild_id);
-
- ///
- /// Adds a member to a guild
- ///
- /// Guild ID
- /// User ID
- /// Access token
- /// User nickname
- /// User roles
- /// Whether this user should be muted on join
- /// Whether this user should be deafened on join
- ///
- public Task AddGuildMemberAsync(ulong guild_id, ulong user_id, string access_token, string nick, IEnumerable roles, bool muted, bool deafened)
- => this.ApiClient.AddGuildMemberAsync(guild_id, user_id, access_token, nick, roles, muted, deafened);
-
- ///
- /// Gets all guild members
- ///
- /// Guild ID
- /// Member download limit
- /// Gets members after this ID
- ///
- public async Task> ListGuildMembersAsync(ulong guild_id, int? limit, ulong? after)
+ ///
+ /// Gets guild bans.
+ ///
+ /// The ID of the guild to get the bans from.
+ /// The number of users to return (up to maximum 1000, default 1000).
+ /// Consider only users before the given user ID.
+ /// Consider only users after the given user ID.
+ /// A collection of the guild's bans.
+ public async Task> GetGuildBansAsync(ulong guild_id, int? limit = null, ulong? before = null, ulong? after = null)
+ => await this.ApiClient.GetGuildBansAsync(guild_id, limit, before, after);
+
+ ///
+ /// Gets the ban of the specified user. Requires Ban Members permission.
+ ///
+ /// The ID of the guild to get the ban from.
+ /// The ID of the user to get the ban for.
+ /// A guild ban object.
+ public async Task GetGuildBanAsync(ulong guild_id, ulong user_id)
+ => await this.ApiClient.GetGuildBanAsync(guild_id, user_id);
+
+ ///
+ /// Creates guild ban
+ ///
+ /// Guild ID
+ /// User ID
+ /// Days to delete messages
+ /// Reason why this member was banned
+ ///
+ public async Task CreateGuildBanAsync(ulong guild_id, ulong user_id, int delete_message_days, string reason)
+ => await this.ApiClient.CreateGuildBanAsync(guild_id, user_id, delete_message_days, reason);
+
+ ///
+ /// Removes a guild ban
+ ///
+ /// Guild ID
+ /// User to unban
+ /// Reason why this member was unbanned
+ ///
+ public async Task RemoveGuildBanAsync(ulong guild_id, ulong user_id, string reason)
+ => await this.ApiClient.RemoveGuildBanAsync(guild_id, user_id, reason);
+
+ ///
+ /// Leaves a guild
+ ///
+ /// Guild ID
+ ///
+ public async Task LeaveGuildAsync(ulong guild_id)
+ => await this.ApiClient.LeaveGuildAsync(guild_id);
+
+ ///
+ /// Adds a member to a guild
+ ///
+ /// Guild ID
+ /// User ID
+ /// Access token
+ /// User nickname
+ /// User roles
+ /// Whether this user should be muted on join
+ /// Whether this user should be deafened on join
+ ///
+ public async Task AddGuildMemberAsync(ulong guild_id, ulong user_id, string access_token, string nick, IEnumerable roles, bool muted, bool deafened)
+ => await this.ApiClient.AddGuildMemberAsync(guild_id, user_id, access_token, muted, deafened, nick, roles);
+
+ ///
+ /// Gets all guild members
+ ///
+ /// Guild ID
+ /// Member download limit
+ /// Gets members after this ID
+ ///
+ public async Task> ListGuildMembersAsync(ulong guild_id, int? limit, ulong? after)
+ {
+ var recmbr = new List();
+
+ var recd = limit ?? 1000;
+ var lim = limit ?? 1000;
+ var last = after;
+ while (recd == lim)
{
- var recmbr = new List();
+ var tms = await this.ApiClient.ListGuildMembersAsync(guild_id, lim, last == 0 ? null : (ulong?)last);
+ recd = tms.Count;
- var recd = limit ?? 1000;
- var lim = limit ?? 1000;
- var last = after;
- while (recd == lim)
+ foreach (var xtm in tms)
{
- var tms = await this.ApiClient.ListGuildMembersAsync(guild_id, lim, last == 0 ? null : (ulong?)last);
- recd = tms.Count;
-
- foreach (var xtm in tms)
- {
- last = xtm.User.Id;
+ last = xtm.User.Id;
- if (this.UserCache.ContainsKey(xtm.User.Id))
- continue;
+ if (this.UserCache.ContainsKey(xtm.User.Id))
+ continue;
- var usr = new DiscordUser(xtm.User) { Discord = this };
- this.UpdateUserCache(usr);
- }
-
- recmbr.AddRange(tms.Select(xtm => new DiscordMember(xtm) { Discord = this, _guild_id = guild_id }));
+ var usr = new DiscordUser(xtm.User) { Discord = this };
+ this.UpdateUserCache(usr);
}
- return new ReadOnlyCollection(recmbr);
+ recmbr.AddRange(tms.Select(xtm => new DiscordMember(xtm) { Discord = this, _guild_id = guild_id }));
}
- ///
- /// Add role to guild member
- ///
- /// Guild ID
- /// User ID
- /// Role ID
- /// Reason this role gets added
- ///
- public Task AddGuildMemberRoleAsync(ulong guild_id, ulong user_id, ulong role_id, string reason)
- => this.ApiClient.AddGuildMemberRoleAsync(guild_id, user_id, role_id, reason);
-
- ///
- /// Remove role from member
- ///
- /// Guild ID
- /// User ID
- /// Role ID
- /// Reason this role gets removed
- ///
- public Task RemoveGuildMemberRoleAsync(ulong guild_id, ulong user_id, ulong role_id, string reason)
- => this.ApiClient.RemoveGuildMemberRoleAsync(guild_id, user_id, role_id, reason);
-
- ///
- /// Updates a role's position
- ///
- /// Guild ID
- /// Role ID
- /// Role position
- /// Reason this position was modified
- ///
- public Task UpdateRolePositionAsync(ulong guild_id, ulong role_id, int position, string reason = null)
- {
- var rgrrps = new List()
- {
- new RestGuildRoleReorderPayload { RoleId = role_id }
- };
- return this.ApiClient.ModifyGuildRolePositionAsync(guild_id, rgrrps, reason);
- }
+ return new ReadOnlyCollection(recmbr);
+ }
- ///
- /// Updates a channel's position
- ///
- /// Guild ID
- /// Channel ID
- /// Channel position
- /// Reason this position was modified
- /// Whether to sync channel permissions with the parent, if moving to a new category.
- /// The new parent id if the channel is to be moved to a new category.
- ///
- public Task UpdateChannelPositionAsync(ulong guild_id, ulong channel_id, int position, string reason, bool? lockPermissions = null, ulong? parentId = null)
+ ///
+ /// Add role to guild member
+ ///
+ /// Guild ID
+ /// User ID
+ /// Role ID
+ /// Reason this role gets added
+ ///
+ public async Task AddGuildMemberRoleAsync(ulong guild_id, ulong user_id, ulong role_id, string reason)
+ => await this.ApiClient.AddGuildMemberRoleAsync(guild_id, user_id, role_id, reason);
+
+ ///
+ /// Remove role from member
+ ///
+ /// Guild ID
+ /// User ID
+ /// Role ID
+ /// Reason this role gets removed
+ ///
+ public async Task RemoveGuildMemberRoleAsync(ulong guild_id, ulong user_id, ulong role_id, string reason)
+ => await this.ApiClient.RemoveGuildMemberRoleAsync(guild_id, user_id, role_id, reason);
+
+ ///
+ /// Updates a role's position
+ ///
+ /// Guild ID
+ /// Role ID
+ /// Role position
+ /// Reason this position was modified
+ ///
+ public async Task UpdateRolePositionAsync(ulong guild_id, ulong role_id, int position, string reason = null)
+ {
+ var rgrrps = new List()
{
- var rgcrps = new List()
- {
- new RestGuildChannelReorderPayload { ChannelId = channel_id, Position = position, LockPermissions = lockPermissions, ParentId = parentId }
- };
- return this.ApiClient.ModifyGuildChannelPositionAsync(guild_id, rgcrps, reason);
- }
+ new RestGuildRoleReorderPayload { RoleId = role_id }
+ };
+ await this.ApiClient.ModifyGuildRolePositionsAsync(guild_id, rgrrps, reason);
+ }
- ///
- /// Gets a guild's widget
- ///
- /// Guild ID
- ///
- public Task GetGuildWidgetAsync(ulong guild_id)
- => this.ApiClient.GetGuildWidgetAsync(guild_id);
-
- ///
- /// Gets a guild's widget settings
- ///
- /// Guild ID
- ///
- public Task GetGuildWidgetSettingsAsync(ulong guild_id)
- => this.ApiClient.GetGuildWidgetSettingsAsync(guild_id);
-
- ///
- /// Modifies a guild's widget settings
- ///
- /// Guild ID
- /// If the widget is enabled or not
- /// Widget channel ID
- /// Reason the widget settings were modified
- ///
- public Task ModifyGuildWidgetSettingsAsync(ulong guild_id, bool? enabled = null, ulong? channel_id = null, string reason = null)
- => this.ApiClient.ModifyGuildWidgetSettingsAsync(guild_id, enabled, channel_id, reason);
-
- ///
- /// Gets a guild's membership screening form.
- ///
- /// Guild ID
- /// The guild's membership screening form.
- public Task GetGuildMembershipScreeningFormAsync(ulong guild_id)
- => this.ApiClient.GetGuildMembershipScreeningFormAsync(guild_id);
-
- ///
- /// Modifies a guild's membership screening form.
- ///
- /// Guild ID
- /// Action to perform
- /// The modified screening form.
- public async Task ModifyGuildMembershipScreeningFormAsync(ulong guild_id, Action action)
+ ///
+ /// Updates a channel's position
+ ///
+ /// Guild ID
+ /// Channel ID
+ /// Channel position
+ /// Reason this position was modified
+ /// Whether to sync channel permissions with the parent, if moving to a new category.
+ /// The new parent id if the channel is to be moved to a new category.
+ ///
+ public async Task UpdateChannelPositionAsync(ulong guild_id, ulong channel_id, int position, string reason, bool? lockPermissions = null, ulong? parentId = null)
+ {
+ var rgcrps = new List()
{
- var mdl = new MembershipScreeningEditModel();
- action(mdl);
- return await this.ApiClient.ModifyGuildMembershipScreeningFormAsync(guild_id, mdl.Enabled, mdl.Fields, mdl.Description);
- }
+ new RestGuildChannelReorderPayload { ChannelId = channel_id, Position = position, LockPermissions = lockPermissions, ParentId = parentId }
+ };
+ await this.ApiClient.ModifyGuildChannelPositionAsync(guild_id, rgcrps, reason);
+ }
- ///
- /// Gets a guild's vanity url
- ///
- /// The ID of the guild.
- /// The guild's vanity url.
- public Task GetGuildVanityUrlAsync(ulong guildId)
- => this.ApiClient.GetGuildVanityUrlAsync(guildId);
-
- ///
- /// Updates the current user's suppress state in a stage channel.
- ///
- /// The ID of the guild.
- /// The ID of the channel.
- /// Toggles the suppress state.
- /// Sets the time the user requested to speak.
- public Task UpdateCurrentUserVoiceStateAsync(ulong guildId, ulong channelId, bool? suppress, DateTimeOffset? requestToSpeakTimestamp = null)
- => this.ApiClient.UpdateCurrentUserVoiceStateAsync(guildId, channelId, suppress, requestToSpeakTimestamp);
-
- ///
- /// Updates a member's suppress state in a stage channel.
- ///
- /// The ID of the guild.
- /// The ID of the member.
- /// The ID of the stage channel.
- /// Toggles the member's suppress state.
- ///
- public Task UpdateUserVoiceStateAsync(ulong guildId, ulong userId, ulong channelId, bool? suppress)
- => this.ApiClient.UpdateUserVoiceStateAsync(guildId, userId, channelId, suppress);
- #endregion
-
- #region Channel
- ///
- /// Creates a guild channel
- ///
- /// Channel ID
- /// Channel name
- /// Channel type
- /// Channel parent ID
- /// Channel topic
- /// Voice channel bitrate
- /// Voice channel user limit
- /// Channel overwrites
- /// Whether this channel should be marked as NSFW
- /// Slow mode timeout for users.
- /// Voice channel video quality mode.
- /// Sorting position of the channel.
- /// Reason this channel was created
- /// Default duration for newly created forum posts in the channel.
- /// Default emoji used for reacting to forum posts.
- /// Tags available for use by forum posts in the channel.
- /// Default sorting order for forum posts in the channel.
- ///
- public Task CreateGuildChannelAsync
+ ///
+ /// Gets a guild's widget
+ ///
+ /// Guild ID
+ ///
+ public async Task GetGuildWidgetAsync(ulong guild_id)
+ => await this.ApiClient.GetGuildWidgetAsync(guild_id);
+
+ ///
+ /// Gets a guild's widget settings
+ ///
+ /// Guild ID
+ ///
+ public async Task GetGuildWidgetSettingsAsync(ulong guild_id)
+ => await this.ApiClient.GetGuildWidgetSettingsAsync(guild_id);
+
+ ///
+ /// Modifies a guild's widget settings
+ ///
+ /// Guild ID
+ /// If the widget is enabled or not
+ /// Widget channel ID
+ /// Reason the widget settings were modified
+ ///
+ public async Task ModifyGuildWidgetSettingsAsync(ulong guild_id, bool? enabled = null, ulong? channel_id = null, string reason = null)
+ => await this.ApiClient.ModifyGuildWidgetSettingsAsync(guild_id, enabled, channel_id, reason);
+
+ ///
+ /// Gets a guild's membership screening form.
+ ///
+ /// Guild ID
+ /// The guild's membership screening form.
+ public async Task GetGuildMembershipScreeningFormAsync(ulong guild_id)
+ => await this.ApiClient.GetGuildMembershipScreeningFormAsync(guild_id);
+
+ ///
+ /// Modifies a guild's membership screening form.
+ ///
+ /// Guild ID
+ /// Action to perform
+ /// The modified screening form.
+ public async Task ModifyGuildMembershipScreeningFormAsync(ulong guild_id, Action action)
+ {
+ var mdl = new MembershipScreeningEditModel();
+ action(mdl);
+ return await this.ApiClient.ModifyGuildMembershipScreeningFormAsync(guild_id, mdl.Enabled, mdl.Fields, mdl.Description);
+ }
+
+ ///
+ /// Gets a guild's vanity url
+ ///
+ /// The ID of the guild.
+ /// The guild's vanity url.
+ public async Task GetGuildVanityUrlAsync(ulong guildId)
+ => await this.ApiClient.GetGuildVanityUrlAsync(guildId);
+
+ ///
+ /// Updates the current user's suppress state in a stage channel.
+ ///
+ /// The ID of the guild.
+ /// The ID of the channel.
+ /// Toggles the suppress state.
+ /// Sets the time the user requested to speak.
+ public async Task UpdateCurrentUserVoiceStateAsync(ulong guildId, ulong channelId, bool? suppress, DateTimeOffset? requestToSpeakTimestamp = null)
+ => await this.ApiClient.UpdateCurrentUserVoiceStateAsync(guildId, channelId, suppress, requestToSpeakTimestamp);
+
+ ///
+ /// Updates a member's suppress state in a stage channel.
+ ///
+ /// The ID of the guild.
+ /// The ID of the member.
+ /// The ID of the stage channel.
+ /// Toggles the member's suppress state.
+ ///
+ public async Task UpdateUserVoiceStateAsync(ulong guildId, ulong userId, ulong channelId, bool? suppress)
+ => await this.ApiClient.UpdateUserVoiceStateAsync(guildId, userId, channelId, suppress);
+ #endregion
+
+ #region Channel
+ ///
+ /// Creates a guild channel
+ ///
+ /// Channel ID
+ /// Channel name
+ /// Channel type
+ /// Channel parent ID
+ /// Channel topic
+ /// Voice channel bitrate
+ /// Voice channel user limit
+ /// Channel overwrites
+ /// Whether this channel should be marked as NSFW
+ /// Slow mode timeout for users.
+ /// Voice channel video quality mode.
+ /// Sorting position of the channel.
+ /// Reason this channel was created
+ /// Default duration for newly created forum posts in the channel.
+ /// Default emoji used for reacting to forum posts.
+ /// Tags available for use by forum posts in the channel.
+ /// Default sorting order for forum posts in the channel.
+ ///
+ public async Task CreateGuildChannelAsync
+ (
+ ulong id,
+ string name,
+ ChannelType type,
+ ulong? parent,
+ Optional topic,
+ int? bitrate,
+ int? userLimit,
+ IEnumerable overwrites,
+ bool? nsfw,
+ Optional perUserRateLimit,
+ VideoQualityMode? qualityMode,
+ int? position,
+ string reason,
+ AutoArchiveDuration? defaultAutoArchiveDuration = null,
+ DefaultReaction? defaultReactionEmoji = null,
+ IEnumerable availableTags = null,
+ DefaultSortOrder? defaultSortOrder = null
+ )
+ {
+ if (type is not (ChannelType.Text or ChannelType.Voice or ChannelType.Category or ChannelType.News or ChannelType.Stage or ChannelType.GuildForum))
+ throw new ArgumentException("Channel type must be text, voice, stage, category, or a forum.", nameof(type));
+
+ return await this.ApiClient.CreateGuildChannelAsync
(
- ulong id,
- string name,
- ChannelType type,
- ulong? parent,
- Optional topic,
- int? bitrate,
- int? userLimit,
- IEnumerable overwrites,
- bool? nsfw,
- Optional perUserRateLimit,
- VideoQualityMode? qualityMode,
- int? position,
- string reason,
- AutoArchiveDuration? defaultAutoArchiveDuration = null,
- DefaultReaction? defaultReactionEmoji = null,
- IEnumerable availableTags = null,
- DefaultSortOrder? defaultSortOrder = null
- )
- {
- if (type is not (ChannelType.Text or ChannelType.Voice or ChannelType.Category or ChannelType.News or ChannelType.Stage or ChannelType.GuildForum))
- throw new ArgumentException("Channel type must be text, voice, stage, category, or a forum.", nameof(type));
-
- return this.ApiClient.CreateGuildChannelAsync
- (
- id,
- name,
- type,
- parent,
- topic,
- bitrate,
- userLimit,
- overwrites,
- nsfw,
- perUserRateLimit,
- qualityMode,
- position,
- reason,
- defaultAutoArchiveDuration,
- defaultReactionEmoji,
- availableTags,
- defaultSortOrder
- );
- }
+ id,
+ name,
+ type,
+ parent,
+ topic,
+ bitrate,
+ userLimit,
+ overwrites,
+ nsfw,
+ perUserRateLimit,
+ qualityMode,
+ position,
+ reason,
+ defaultAutoArchiveDuration,
+ defaultReactionEmoji,
+ availableTags,
+ defaultSortOrder
+ );
+ }
- ///
- /// Modifies a channel
- ///
- /// Channel ID
- /// New channel name
- /// New channel position
- /// New channel topic
- /// Whether this channel should be marked as NSFW
- /// New channel parent
- /// New voice channel bitrate
- /// New voice channel user limit
- /// Slow mode timeout for users.
- /// New region override.
- /// New video quality mode.
- /// New channel type.
- /// New channel permission overwrites.
- /// Reason why this channel was modified
- /// Channel flags.
- /// Default duration for newly created forum posts in the channel.
- /// Default emoji used for reacting to forum posts.
- /// Tags available for use by forum posts in the channel.
- /// Default per-user ratelimit for forum posts in the channel.
- /// Default sorting order for forum posts in the channel.
- /// Default layout for forum posts in the channel.
- ///
- public Task ModifyChannelAsync
+ ///
+ /// Modifies a channel
+ ///
+ /// Channel ID
+ /// New channel name
+ /// New channel position
+ /// New channel topic
+ /// Whether this channel should be marked as NSFW
+ /// New channel parent
+ /// New voice channel bitrate
+ /// New voice channel user limit
+ /// Slow mode timeout for users.
+ /// New region override.
+ /// New video quality mode.
+ /// New channel type.
+ /// New channel permission overwrites.
+ /// Reason why this channel was modified
+ /// Channel flags.
+ /// Default duration for newly created forum posts in the channel.
+ /// Default emoji used for reacting to forum posts.
+ /// Tags available for use by forum posts in the channel.
+ /// Default per-user ratelimit for forum posts in the channel.
+ /// Default sorting order for forum posts in the channel.
+ /// Default layout for forum posts in the channel.
+ ///
+ public async Task ModifyChannelAsync
+ (
+ ulong id,
+ string name,
+ int? position,
+ Optional topic,
+ bool? nsfw,
+ Optional parent,
+ int? bitrate,
+ int? userLimit,
+ Optional perUserRateLimit,
+ Optional rtcRegion,
+ VideoQualityMode? qualityMode,
+ Optional type,
+ IEnumerable permissionOverwrites,
+ string reason,
+ Optional flags,
+ IEnumerable? availableTags,
+ Optional defaultAutoArchiveDuration,
+ Optional defaultReactionEmoji,
+ Optional defaultPerUserRatelimit,
+ Optional defaultSortOrder,
+ Optional defaultForumLayout
+ )
+ => await this.ApiClient.ModifyChannelAsync
(
- ulong id,
- string name,
- int? position,
- Optional topic,
- bool? nsfw,
- Optional parent,
- int? bitrate,
- int? userLimit,
- Optional perUserRateLimit,
- Optional rtcRegion,
- VideoQualityMode? qualityMode,
- Optional type,
- IEnumerable permissionOverwrites,
- string reason,
- Optional flags,
- IEnumerable? availableTags,
- Optional defaultAutoArchiveDuration,
- Optional defaultReactionEmoji,
- Optional defaultPerUserRatelimit,
- Optional defaultSortOrder,
- Optional defaultForumLayout
- )
- => this.ApiClient.ModifyChannelAsync
- (
- id,
- name,
- position,
- topic,
- nsfw,
- parent,
- bitrate,
- userLimit,
- perUserRateLimit,
- rtcRegion.IfPresent(e => e?.Id),
- qualityMode,
- type,
- permissionOverwrites,
- reason,
- flags,
- availableTags,
- defaultAutoArchiveDuration,
- defaultReactionEmoji,
- defaultPerUserRatelimit,
- defaultSortOrder,
- defaultForumLayout
- );
-
- ///
- /// Modifies a channel
- ///
- /// Channel ID
- /// Channel modifications
- ///
- public Task ModifyChannelAsync(ulong channelId, Action action)
- {
- var mdl = new ChannelEditModel();
- action(mdl);
-
- return this.ApiClient.ModifyChannelAsync
- (
- channelId, mdl.Name,
- mdl.Position,
- mdl.Topic,
- mdl.Nsfw,
- mdl.Parent.HasValue ? mdl.Parent.Value?.Id : default(Optional),
- mdl.Bitrate,
- mdl.Userlimit,
- mdl.PerUserRateLimit,
- mdl.RtcRegion.IfPresent(r => r?.Id),
- mdl.QualityMode,
- mdl.Type,
- mdl.PermissionOverwrites,
- mdl.AuditLogReason,
- mdl.Flags,
- mdl.AvailableTags,
- mdl.DefaultAutoArchiveDuration,
- mdl.DefaultReaction,
- mdl.DefaultThreadRateLimit,
- mdl.DefaultSortOrder,
- mdl.DefaultForumLayout
- );
- }
+ id,
+ name,
+ position,
+ topic,
+ nsfw,
+ parent,
+ bitrate,
+ userLimit,
+ perUserRateLimit,
+ rtcRegion.IfPresent(e => e?.Id),
+ qualityMode,
+ type,
+ permissionOverwrites,
+ flags,
+ availableTags,
+ defaultAutoArchiveDuration,
+ defaultReactionEmoji,
+ defaultPerUserRatelimit,
+ defaultSortOrder,
+ defaultForumLayout,
+ reason
+ );
+
+ ///
+ /// Modifies a channel
+ ///
+ /// Channel ID
+ /// Channel modifications
+ ///
+ public async Task ModifyChannelAsync(ulong channelId, Action action)
+ {
+ var mdl = new ChannelEditModel();
+ action(mdl);
- ///
- /// Gets a channel object
- ///
- /// Channel ID
- ///
- public Task GetChannelAsync(ulong id)
- => this.ApiClient.GetChannelAsync(id);
-
- ///
- /// Deletes a channel
- ///
- /// Channel ID
- /// Reason why this channel was deleted
- ///
- public Task DeleteChannelAsync(ulong id, string reason)
- => this.ApiClient.DeleteChannelAsync(id, reason);
-
- ///
- /// Gets message in a channel
- ///
- /// Channel ID
- /// Message ID
- ///
- public Task GetMessageAsync(ulong channel_id, ulong message_id)
- => this.ApiClient.GetMessageAsync(channel_id, message_id);
-
- ///
- /// Sends a message
- ///
- /// Channel ID
- /// Message (text) content
- ///
- public Task CreateMessageAsync(ulong channel_id, string content)
- => this.ApiClient.CreateMessageAsync(channel_id, content, null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
-
- ///
- /// Sends a message
- ///
- /// Channel ID
- /// Embed to attach
- ///
- public Task CreateMessageAsync(ulong channel_id, DiscordEmbed embed)
- => this.ApiClient.CreateMessageAsync(channel_id, null, embed != null ? new[] { embed } : null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
-
- ///
- /// Sends a message
- ///
- /// Channel ID
- /// Message (text) content
- /// Embed to attach
- ///
- public Task CreateMessageAsync(ulong channel_id, string content, DiscordEmbed embed)
- => this.ApiClient.CreateMessageAsync(channel_id, content, embed != null ? new[] { embed } : null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
-
- ///
- /// Sends a message
- ///
- /// Channel ID
- /// The Discord Message builder.
- ///
- public Task CreateMessageAsync(ulong channel_id, DiscordMessageBuilder builder)
- => this.ApiClient.CreateMessageAsync(channel_id, builder);
-
- ///
- /// Sends a message
- ///
- /// Channel ID
- /// The Discord Message builder.
- ///
- public Task CreateMessageAsync(ulong channel_id, Action action)
- {
- var builder = new DiscordMessageBuilder();
- action(builder);
- return this.ApiClient.CreateMessageAsync(channel_id, builder);
- }
+ await this.ApiClient.ModifyChannelAsync
+ (
+ channelId, mdl.Name,
+ mdl.Position,
+ mdl.Topic,
+ mdl.Nsfw,
+ mdl.Parent.HasValue ? mdl.Parent.Value?.Id : default(Optional),
+ mdl.Bitrate,
+ mdl.Userlimit,
+ mdl.PerUserRateLimit,
+ mdl.RtcRegion.IfPresent(r => r?.Id),
+ mdl.QualityMode,
+ mdl.Type,
+ mdl.PermissionOverwrites,
+ mdl.Flags,
+ mdl.AvailableTags,
+ mdl.DefaultAutoArchiveDuration,
+ mdl.DefaultReaction,
+ mdl.DefaultThreadRateLimit,
+ mdl.DefaultSortOrder,
+ mdl.DefaultForumLayout,
+ mdl.AuditLogReason
+ );
+ }
- ///
- /// Gets channels from a guild
- ///
- /// Guild ID
- ///
- public Task> GetGuildChannelsAsync(ulong guild_id)
- => this.ApiClient.GetGuildChannelsAsync(guild_id);
-
- ///
- /// Gets messages from a channel
- ///
- /// Channel ID
- /// Limit of messages to get
- /// Gets messages before this ID
- /// Gets messages after this ID
- /// Gets messages around this ID
- ///
- public Task> GetChannelMessagesAsync(ulong channel_id, int limit, ulong? before, ulong? after, ulong? around)
- => this.ApiClient.GetChannelMessagesAsync(channel_id, limit, before, after, around);
-
- ///
- /// Gets a message from a channel
- ///
- /// Channel ID
- /// Message ID
- ///
- public Task GetChannelMessageAsync(ulong channel_id, ulong message_id)
- => this.ApiClient.GetChannelMessageAsync(channel_id, message_id);
-
- ///
- /// Edits a message
- ///
- /// Channel ID
- /// Message ID
- /// New message content
- ///
- public Task EditMessageAsync(ulong channel_id, ulong message_id, Optional content)
- => this.ApiClient.EditMessageAsync(channel_id, message_id, content, default, default, default, Array.Empty(), null, default);
-
- ///
- /// Edits a message
- ///
- /// Channel ID
- /// Message ID
- /// New message embed
- ///
- public Task EditMessageAsync(ulong channel_id, ulong message_id, Optional embed)
- => this.ApiClient.EditMessageAsync(channel_id, message_id, default, embed.HasValue ? new[] { embed.Value } : Array.Empty(), default, default, Array.Empty(), null, default);
-
- ///
- /// Edits a message
- ///
- /// Channel ID
- /// Message ID
- /// The builder of the message to edit.
- /// Whether to suppress embeds on the message.
- /// Attached files to keep.
- ///
- public async Task EditMessageAsync(ulong channel_id, ulong message_id, DiscordMessageBuilder builder, bool suppressEmbeds = false, IEnumerable attachments = default)
- {
- builder.Validate(true);
+ ///
+ /// Gets a channel object
+ ///
+ /// Channel ID
+ ///
+ public async Task GetChannelAsync(ulong id)
+ => await this.ApiClient.GetChannelAsync(id);
+
+ ///
+ /// Deletes a channel
+ ///
+ /// Channel ID
+ /// Reason why this channel was deleted
+ ///
+ public async Task DeleteChannelAsync(ulong id, string reason)
+ => await this.ApiClient.DeleteChannelAsync(id, reason);
+
+ ///
+ /// Gets message in a channel
+ ///
+ /// Channel ID
+ /// Message ID
+ ///
+ public async Task GetMessageAsync(ulong channel_id, ulong message_id)
+ => await this.ApiClient.GetMessageAsync(channel_id, message_id);
+
+ ///
+ /// Sends a message
+ ///
+ /// Channel ID
+ /// Message (text) content
+ ///
+ public async Task CreateMessageAsync(ulong channel_id, string content)
+ => await this.ApiClient.CreateMessageAsync(channel_id, content, null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
+
+ ///
+ /// Sends a message
+ ///
+ /// Channel ID
+ /// Embed to attach
+ ///
+ public async Task CreateMessageAsync(ulong channel_id, DiscordEmbed embed)
+ => await this.ApiClient.CreateMessageAsync(channel_id, null, embed != null ? new[] { embed } : null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
+
+ ///
+ /// Sends a message
+ ///
+ /// Channel ID
+ /// Message (text) content
+ /// Embed to attach
+ ///
+ public async Task CreateMessageAsync(ulong channel_id, string content, DiscordEmbed embed)
+ => await this.ApiClient.CreateMessageAsync(channel_id, content, embed != null ? new[] { embed } : null, replyMessageId: null, mentionReply: false, failOnInvalidReply: false, suppressNotifications: false);
+
+ ///
+ /// Sends a message
+ ///
+ /// Channel ID
+ /// The Discord Message builder.
+ ///
+ public async Task CreateMessageAsync(ulong channel_id, DiscordMessageBuilder builder)
+ => await this.ApiClient.CreateMessageAsync(channel_id, builder);
+
+ ///
+ /// Sends a message
+ ///
+ /// Channel ID
+ /// The Discord Message builder.
+ ///
+ public async Task CreateMessageAsync(ulong channel_id, Action action)
+ {
+ var builder = new DiscordMessageBuilder();
+ action(builder);
+ return await this.ApiClient.CreateMessageAsync(channel_id, builder);
+ }
- return await this.ApiClient.EditMessageAsync(channel_id, message_id, builder.Content, new Optional>(builder.Embeds), builder._mentions, builder.Components, builder.Files, suppressEmbeds ? MessageFlags.SuppressedEmbeds : null, attachments);
- }
+ ///
+ /// Gets channels from a guild
+ ///
+ /// Guild ID
+ ///
+ public async Task> GetGuildChannelsAsync(ulong guild_id)
+ => await this.ApiClient.GetGuildChannelsAsync(guild_id);
+
+ ///
+ /// Gets messages from a channel
+ ///
+ /// Channel ID
+ /// Limit of messages to get
+ /// Gets messages before this ID
+ /// Gets messages after this ID
+ /// Gets messages around this ID
+ ///
+ public async Task> GetChannelMessagesAsync(ulong channel_id, int limit, ulong? before, ulong? after, ulong? around)
+ => await this.ApiClient.GetChannelMessagesAsync(channel_id, limit, before, after, around);
+
+ ///
+ /// Gets a message from a channel
+ ///
+ /// Channel ID
+ /// Message ID
+ ///
+ public async Task GetChannelMessageAsync(ulong channel_id, ulong message_id)
+ => await this.ApiClient.GetChannelMessageAsync(channel_id, message_id);
+
+ ///
+ /// Edits a message
+ ///
+ /// Channel ID
+ /// Message ID
+ /// New message content
+ ///
+ public async Task EditMessageAsync(ulong channel_id, ulong message_id, Optional content)
+ => await this.ApiClient.EditMessageAsync(channel_id, message_id, content, default, default, default, Array.Empty(), null, default);
+
+ ///
+ /// Edits a message
+ ///
+ /// Channel ID
+ /// Message ID
+ /// New message embed
+ ///
+ public async Task EditMessageAsync(ulong channel_id, ulong message_id, Optional embed)
+ => await this.ApiClient.EditMessageAsync(channel_id, message_id, default, embed.HasValue ? new[] { embed.Value } : Array.Empty(), default, default, Array.Empty(), null, default);
+
+ ///
+ /// Edits a message
+ ///
+ /// Channel ID
+ /// Message ID
+ /// The builder of the message to edit.
+ /// Whether to suppress embeds on the message.
+ /// Attached files to keep.
+ ///
+ public async Task EditMessageAsync(ulong channel_id, ulong message_id, DiscordMessageBuilder builder, bool suppressEmbeds = false, IEnumerable attachments = default)
+ {
+ builder.Validate(true);
- ///
- /// Modifies the visibility of embeds in a message.
- ///
- /// Channel ID
- /// Message ID
- /// Whether to hide all embeds.
- public Task ModifyEmbedSuppressionAsync(ulong channel_id, ulong message_id, bool hideEmbeds)
- => this.ApiClient.EditMessageAsync(channel_id, message_id, default, default, default, default, Array.Empty(), hideEmbeds ? MessageFlags.SuppressedEmbeds : null, default);
-
- ///
- /// Deletes a message
- ///
- /// Channel ID
- /// Message ID
- /// Why this message was deleted
- ///
- public Task DeleteMessageAsync(ulong channel_id, ulong message_id, string reason)
- => this.ApiClient.DeleteMessageAsync(channel_id, message_id, reason);
-
- ///
- /// Deletes multiple messages
- ///
- /// Channel ID
- /// Message IDs
- /// Reason these messages were deleted
- ///
- public Task DeleteMessagesAsync(ulong channel_id, IEnumerable message_ids, string reason)
- => this.ApiClient.DeleteMessagesAsync(channel_id, message_ids, reason);
-
- ///
- /// Gets a channel's invites
- ///
- /// Channel ID
- ///
- public Task> GetChannelInvitesAsync(ulong channel_id)
- => this.ApiClient.GetChannelInvitesAsync(channel_id);
-
- ///
- /// Creates a channel invite
- ///
- /// Channel ID
- /// For how long the invite should exist
- /// How often the invite may be used
- /// Whether this invite should be temporary
- /// Whether this invite should be unique (false might return an existing invite)
- /// Why you made an invite
- /// The target type of the invite, for stream and embedded application invites.
- /// The ID of the target user.
- /// The ID of the target application.
- ///
- public Task CreateChannelInviteAsync(ulong channel_id, int max_age, int max_uses, bool temporary, bool unique, string reason, InviteTargetType? targetType = null, ulong? targetUserId = null, ulong? targetApplicationId = null)
- => this.ApiClient.CreateChannelInviteAsync(channel_id, max_age, max_uses, temporary, unique, reason, targetType, targetUserId, targetApplicationId);
-
- ///
- /// Deletes channel overwrite
- ///
- /// Channel ID
- /// Overwrite ID
- /// Reason it was deleted
- ///
- public Task DeleteChannelPermissionAsync(ulong channel_id, ulong overwrite_id, string reason)
- => this.ApiClient.DeleteChannelPermissionAsync(channel_id, overwrite_id, reason);
-
- ///
- /// Edits channel overwrite
- ///
- /// Channel ID
- /// Overwrite ID
- /// Permissions to allow
- /// Permissions to deny
- /// Overwrite type
- /// Reason this overwrite was created
- ///
- public Task EditChannelPermissionsAsync(ulong channel_id, ulong overwrite_id, Permissions allow, Permissions deny, string type, string reason)
- => this.ApiClient.EditChannelPermissionsAsync(channel_id, overwrite_id, allow, deny, type, reason);
-
- ///
- /// Send a typing indicator to a channel
- ///
- /// Channel ID
- ///
- public Task TriggerTypingAsync(ulong channel_id)
- => this.ApiClient.TriggerTypingAsync(channel_id);
-
- ///
- /// Gets pinned messages
- ///
- /// Channel ID
- ///
- public Task> GetPinnedMessagesAsync(ulong channel_id)
- => this.ApiClient.GetPinnedMessagesAsync(channel_id);
-
- ///
- /// Unpins a message
- ///
- /// Channel ID
- /// Message ID
- ///
- public Task UnpinMessageAsync(ulong channel_id, ulong message_id)
- => this.ApiClient.UnpinMessageAsync(channel_id, message_id);
-
- ///
- /// Joins a group DM
- ///
- /// Channel ID
- /// DM nickname
- ///
- public Task JoinGroupDmAsync(ulong channel_id, string nickname)
- => this.ApiClient.AddGroupDmRecipientAsync(channel_id, this.CurrentUser.Id, this.Configuration.Token, nickname);
-
- ///
- /// Adds a member to a group DM
- ///
- /// Channel ID
- /// User ID
- /// User's access token
- /// Nickname for user
- ///
- public Task GroupDmAddRecipientAsync(ulong channel_id, ulong user_id, string access_token, string nickname)
- => this.ApiClient.AddGroupDmRecipientAsync(channel_id, user_id, access_token, nickname);
-
- ///
- /// Leaves a group DM
- ///
- /// Channel ID
- ///
- public Task LeaveGroupDmAsync(ulong channel_id)
- => this.ApiClient.RemoveGroupDmRecipientAsync(channel_id, this.CurrentUser.Id);
-
- ///
- /// Removes a member from a group DM
- ///
- /// Channel ID
- /// User ID
- ///
- public Task GroupDmRemoveRecipientAsync(ulong channel_id, ulong user_id)
- => this.ApiClient.RemoveGroupDmRecipientAsync(channel_id, user_id);
-
- ///
- /// Creates a group DM
- ///
- /// Access tokens
- /// Nicknames per user
- ///
- public Task CreateGroupDmAsync(IEnumerable access_tokens, IDictionary nicks)
- => this.ApiClient.CreateGroupDmAsync(access_tokens, nicks);
-
- ///
- /// Creates a group DM with current user
- ///
- /// Access tokens
- /// Nicknames
- ///
- public Task CreateGroupDmWithCurrentUserAsync(IEnumerable access_tokens, IDictionary nicks)
- {
- var a = access_tokens.ToList();
- a.Add(this.Configuration.Token);
- return this.ApiClient.CreateGroupDmAsync(a, nicks);
- }
+ return await this.ApiClient.EditMessageAsync(channel_id, message_id, builder.Content, new Optional>(builder.Embeds), builder._mentions, builder.Components, builder.Files, suppressEmbeds ? MessageFlags.SuppressedEmbeds : null, attachments);
+ }
- ///
- /// Creates a DM
- ///
- /// Recipient user ID
- ///
- public Task CreateDmAsync(ulong recipient_id)
- => this.ApiClient.CreateDmAsync(recipient_id);
-
- ///
- /// Follows a news channel
- ///
- /// ID of the channel to follow
- /// ID of the channel to crosspost messages to
- /// Thrown when the current user doesn't have on the target channel
- public Task FollowChannelAsync(ulong channel_id, ulong webhook_channel_id)
- => this.ApiClient.FollowChannelAsync(channel_id, webhook_channel_id);
-
- ///
- /// Publishes a message in a news channel to following channels
- ///
- /// ID of the news channel the message to crosspost belongs to
- /// ID of the message to crosspost
- ///
- /// Thrown when the current user doesn't have and/or
- ///
- public Task CrosspostMessageAsync(ulong channel_id, ulong message_id)
- => this.ApiClient.CrosspostMessageAsync(channel_id, message_id);
-
- ///
- /// Creates a stage instance in a stage channel.
- ///
- /// The ID of the stage channel to create it in.
- /// The topic of the stage instance.
- /// The privacy level of the stage instance.
- /// The reason the stage instance was created.
- /// The created stage instance.
- public Task CreateStageInstanceAsync(ulong channelId, string topic, PrivacyLevel? privacyLevel = null, string reason = null)
- => this.ApiClient.CreateStageInstanceAsync(channelId, topic, privacyLevel, reason);
-
- ///
- /// Gets a stage instance in a stage channel.
- ///
- /// The ID of the channel.
- /// The stage instance in the channel.
- public Task GetStageInstanceAsync(ulong channelId)
- => this.ApiClient.GetStageInstanceAsync(channelId);
-
- ///
- /// Modifies a stage instance in a stage channel.
- ///
- /// The ID of the channel to modify the stage instance of.
- /// Action to perform.
- /// The modified stage instance.
- public async Task ModifyStageInstanceAsync(ulong channelId, Action action)
- {
- var mdl = new StageInstanceEditModel();
- action(mdl);
- return await this.ApiClient.ModifyStageInstanceAsync(channelId, mdl.Topic, mdl.PrivacyLevel, mdl.AuditLogReason);
- }
+ ///
+ /// Modifies the visibility of embeds in a message.
+ ///
+ /// Channel ID
+ /// Message ID
+ /// Whether to hide all embeds.
+ public async Task ModifyEmbedSuppressionAsync(ulong channel_id, ulong message_id, bool hideEmbeds)
+ => await this.ApiClient.EditMessageAsync(channel_id, message_id, default, default, default, default, Array.Empty(), hideEmbeds ? MessageFlags.SuppressedEmbeds : null, default);
+
+ ///
+ /// Deletes a message
+ ///
+ /// Channel ID
+ /// Message ID
+ /// Why this message was deleted
+ ///
+ public async Task DeleteMessageAsync(ulong channel_id, ulong message_id, string reason)
+ => await this.ApiClient.DeleteMessageAsync(channel_id, message_id, reason);
+
+ ///
+ /// Deletes multiple messages
+ ///
+ /// Channel ID
+ /// Message IDs
+ /// Reason these messages were deleted
+ ///
+ public async Task DeleteMessagesAsync(ulong channel_id, IEnumerable message_ids, string reason)
+ => await this.ApiClient.DeleteMessagesAsync(channel_id, message_ids, reason);
+
+ ///
+ /// Gets a channel's invites
+ ///
+ /// Channel ID
+ ///
+ public async Task> GetChannelInvitesAsync(ulong channel_id)
+ => await this.ApiClient.GetChannelInvitesAsync(channel_id);
+
+ ///
+ /// Creates a channel invite
+ ///
+ /// Channel ID
+ /// For how long the invite should exist
+ /// How often the invite may be used
+ /// Whether this invite should be temporary
+ /// Whether this invite should be unique (false might return an existing invite)
+ /// Why you made an invite
+ /// The target type of the invite, for stream and embedded application invites.
+ /// The ID of the target user.
+ /// The ID of the target application.
+ ///
+ public async Task CreateChannelInviteAsync(ulong channel_id, int max_age, int max_uses, bool temporary, bool unique, string reason, InviteTargetType? targetType = null, ulong? targetUserId = null, ulong? targetApplicationId = null)
+ => await this.ApiClient.CreateChannelInviteAsync(channel_id, max_age, max_uses, temporary, unique, reason, targetType, targetUserId, targetApplicationId);
+
+ ///
+ /// Deletes channel overwrite
+ ///
+ /// Channel ID
+ /// Overwrite ID
+ /// Reason it was deleted
+ ///
+ public async Task DeleteChannelPermissionAsync(ulong channel_id, ulong overwrite_id, string reason)
+ => await this.ApiClient.DeleteChannelPermissionAsync(channel_id, overwrite_id, reason);
+
+ ///
+ /// Edits channel overwrite
+ ///
+ /// Channel ID
+ /// Overwrite ID
+ /// Permissions to allow
+ /// Permissions to deny
+ /// Overwrite type
+ /// Reason this overwrite was created
+ ///
+ public async Task EditChannelPermissionsAsync(ulong channel_id, ulong overwrite_id, Permissions allow, Permissions deny, string type, string reason)
+ => await this.ApiClient.EditChannelPermissionsAsync(channel_id, overwrite_id, allow, deny, type, reason);
+
+ ///
+ /// Send a typing indicator to a channel
+ ///
+ /// Channel ID
+ ///
+ public async Task TriggerTypingAsync(ulong channel_id)
+ => await this.ApiClient.TriggerTypingAsync(channel_id);
+
+ ///
+ /// Gets pinned messages
+ ///
+ /// Channel ID
+ ///
+ public async Task> GetPinnedMessagesAsync(ulong channel_id)
+ => await this.ApiClient.GetPinnedMessagesAsync(channel_id);
+
+ ///
+ /// Unpins a message
+ ///
+ /// Channel ID
+ /// Message ID
+ ///
+ public async Task UnpinMessageAsync(ulong channel_id, ulong message_id)
+ => await this.ApiClient.UnpinMessageAsync(channel_id, message_id);
+
+ ///
+ /// Joins a group DM
+ ///
+ /// Channel ID
+ /// DM nickname
+ ///
+ public async Task JoinGroupDmAsync(ulong channel_id, string nickname)
+ => await this.ApiClient.AddGroupDmRecipientAsync(channel_id, this.CurrentUser.Id, this.Configuration.Token, nickname);
+
+ ///
+ /// Adds a member to a group DM
+ ///
+ /// Channel ID
+ /// User ID
+ /// User's access token
+ /// Nickname for user
+ ///
+ public async Task GroupDmAddRecipientAsync(ulong channel_id, ulong user_id, string access_token, string nickname)
+ => await this.ApiClient.AddGroupDmRecipientAsync(channel_id, user_id, access_token, nickname);
+
+ ///
+ /// Leaves a group DM
+ ///
+ /// Channel ID
+ ///
+ public async Task LeaveGroupDmAsync(ulong channel_id)
+ => await this.ApiClient.RemoveGroupDmRecipientAsync(channel_id, this.CurrentUser.Id);
+
+ ///
+ /// Removes a member from a group DM
+ ///
+ /// Channel ID
+ /// User ID
+ ///
+ public async Task GroupDmRemoveRecipientAsync(ulong channel_id, ulong user_id)
+ => await this.ApiClient.RemoveGroupDmRecipientAsync(channel_id, user_id);
+
+ ///
+ /// Creates a group DM
+ ///
+ /// Access tokens
+ /// Nicknames per user
+ ///
+ public async Task CreateGroupDmAsync(IEnumerable access_tokens, IDictionary nicks)
+ => await this.ApiClient.CreateGroupDmAsync(access_tokens, nicks);
+
+ ///
+ /// Creates a group DM with current user
+ ///
+ /// Access tokens
+ /// Nicknames
+ ///
+ public async Task CreateGroupDmWithCurrentUserAsync(IEnumerable access_tokens, IDictionary nicks)
+ {
+ var a = access_tokens.ToList();
+ a.Add(this.Configuration.Token);
+ return await this.ApiClient.CreateGroupDmAsync(a, nicks);
+ }
- ///
- /// Deletes a stage instance in a stage channel.
- ///
- /// The ID of the channel to delete the stage instance of.
- /// The reason the stage instance was deleted.
- public Task DeleteStageInstanceAsync(ulong channelId, string reason = null)
- => this.ApiClient.DeleteStageInstanceAsync(channelId, reason);
-
- ///
- /// Pins a message.
- ///
- /// The ID of the channel the message is in.
- /// The ID of the message.
- public Task PinMessageAsync(ulong channelId, ulong messageId)
- => this.ApiClient.PinMessageAsync(channelId, messageId);
-
- #endregion
-
- #region Member
- ///
- /// Gets current user object
- ///
- ///
- public Task GetCurrentUserAsync()
- => this.ApiClient.GetCurrentUserAsync();
-
- ///
- /// Gets user object
- ///
- /// User ID
- ///
- public Task GetUserAsync(ulong user)
- => this.ApiClient.GetUserAsync(user);
-
- ///
- /// Gets guild member
- ///
- /// Guild ID
- /// Member ID
- ///
- public Task GetGuildMemberAsync(ulong guild_id, ulong member_id)
- => this.ApiClient.GetGuildMemberAsync(guild_id, member_id);
-
- ///
- /// Removes guild member
- ///
- /// Guild ID
- /// User ID
- /// Why this user was removed
- ///
- public Task RemoveGuildMemberAsync(ulong guild_id, ulong user_id, string reason)
- => this.ApiClient.RemoveGuildMemberAsync(guild_id, user_id, reason);
-
- ///
- /// Modifies current user
- ///
- /// New username
- /// New avatar (base64)
- ///
- public async Task ModifyCurrentUserAsync(string username, string base64_avatar)
- => new DiscordUser(await this.ApiClient.ModifyCurrentUserAsync(username, base64_avatar)) { Discord = this };
-
- ///
- /// Modifies current user
- ///
- /// username
- /// avatar
- ///
- public async Task ModifyCurrentUserAsync(string username = null, Stream avatar = null)
- {
- string av64 = null;
- if (avatar != null)
- using (var imgtool = new ImageTool(avatar))
- av64 = imgtool.GetBase64();
+ ///
+ /// Creates a DM
+ ///
+ /// Recipient user ID
+ ///
+ public async Task CreateDmAsync(ulong recipient_id)
+ => await this.ApiClient.CreateDmAsync(recipient_id);
+
+ ///
+ /// Follows a news channel
+ ///
+ /// ID of the channel to follow
+ /// ID of the channel to crosspost messages to
+ /// Thrown when the current user doesn't have on the target channel
+ public async Task FollowChannelAsync(ulong channel_id, ulong webhook_channel_id)
+ => await this.ApiClient.FollowChannelAsync(channel_id, webhook_channel_id);
+
+ ///
+ /// Publishes a message in a news channel to following channels
+ ///
+ /// ID of the news channel the message to crosspost belongs to
+ /// ID of the message to crosspost
+ ///
+ /// Thrown when the current user doesn't have and/or
+ ///
+ public async Task CrosspostMessageAsync(ulong channel_id, ulong message_id)
+ => await this.ApiClient.CrosspostMessageAsync(channel_id, message_id);
+
+ ///
+ /// Creates a stage instance in a stage channel.
+ ///
+ /// The ID of the stage channel to create it in.
+ /// The topic of the stage instance.
+ /// The privacy level of the stage instance.
+ /// The reason the stage instance was created.
+ /// The created stage instance.
+ public async Task CreateStageInstanceAsync(ulong channelId, string topic, PrivacyLevel? privacyLevel = null, string reason = null)
+ => await this.ApiClient.CreateStageInstanceAsync(channelId, topic, privacyLevel, reason);
+
+ ///
+ /// Gets a stage instance in a stage channel.
+ ///
+ /// The ID of the channel.
+ /// The stage instance in the channel.
+ public async Task GetStageInstanceAsync(ulong channelId)
+ => await this.ApiClient.GetStageInstanceAsync(channelId);
+
+ ///
+ /// Modifies a stage instance in a stage channel.
+ ///
+ /// The ID of the channel to modify the stage instance of.
+ /// Action to perform.
+ /// The modified stage instance.
+ public async Task ModifyStageInstanceAsync(ulong channelId, Action action)
+ {
+ var mdl = new StageInstanceEditModel();
+ action(mdl);
+ return await this.ApiClient.ModifyStageInstanceAsync(channelId, mdl.Topic, mdl.PrivacyLevel, mdl.AuditLogReason);
+ }
- return new DiscordUser(await this.ApiClient.ModifyCurrentUserAsync(username, av64)) { Discord = this };
- }
+ ///
+ /// Deletes a stage instance in a stage channel.
+ ///
+ /// The ID of the channel to delete the stage instance of.
+ /// The reason the stage instance was deleted.
+ public async Task DeleteStageInstanceAsync(ulong channelId, string reason = null)
+ => await this.ApiClient.DeleteStageInstanceAsync(channelId, reason);
+
+ ///
+ /// Pins a message.
+ ///
+ /// The ID of the channel the message is in.
+ /// The ID of the message.
+ public async Task PinMessageAsync(ulong channelId, ulong messageId)
+ => await this.ApiClient.PinMessageAsync(channelId, messageId);
+
+ #endregion
+
+ #region Member
+ ///
+ /// Gets current user object
+ ///
+ ///
+ public async Task GetCurrentUserAsync()
+ => await this.ApiClient.GetCurrentUserAsync();
+
+ ///
+ /// Gets user object
+ ///
+ /// User ID
+ ///
+ public async Task GetUserAsync(ulong user)
+ => await this.ApiClient.GetUserAsync(user);
+
+ ///
+ /// Gets guild member
+ ///
+ /// Guild ID
+ /// Member ID
+ ///
+ public async Task GetGuildMemberAsync(ulong guild_id, ulong member_id)
+ => await this.ApiClient.GetGuildMemberAsync(guild_id, member_id);
+
+ ///
+ /// Removes guild member
+ ///
+ /// Guild ID
+ /// User ID
+ /// Why this user was removed
+ ///
+ public async Task RemoveGuildMemberAsync(ulong guild_id, ulong user_id, string reason)
+ => await this.ApiClient.RemoveGuildMemberAsync(guild_id, user_id, reason);
+
+ ///
+ /// Modifies current user
+ ///
+ /// New username
+ /// New avatar (base64)
+ ///
+ public async Task ModifyCurrentUserAsync(string username, string base64_avatar)
+ => new DiscordUser(await this.ApiClient.ModifyCurrentUserAsync(username, base64_avatar)) { Discord = this };
+
+ ///
+ /// Modifies current user
+ ///
+ /// username
+ /// avatar
+ ///
+ public async Task ModifyCurrentUserAsync(string username = null, Stream avatar = null)
+ {
+ string av64 = null;
+ if (avatar != null)
+ using (var imgtool = new ImageTool(avatar))
+ av64 = imgtool.GetBase64();
- ///
- /// Gets current user's guilds
- ///
- /// Limit of guilds to get
- /// Gets guild before ID
- /// Gets guilds after ID
- ///
- public Task> GetCurrentUserGuildsAsync(int limit = 100, ulong? before = null, ulong? after = null)
- => this.ApiClient.GetCurrentUserGuildsAsync(limit, before, after);
-
- ///
- /// Modifies guild member.
- ///
- /// Guild ID
- /// User ID
- /// New nickname
- /// New roles
- /// Whether this user should be muted
- /// Whether this user should be deafened
- /// Voice channel to move this user to
- /// How long this member should be timed out for. Requires MODERATE_MEMBERS permission.
- /// Reason this user was modified
- ///
- public Task ModifyGuildMemberAsync(ulong guild_id, ulong user_id, Optional nick,
- Optional> role_ids, Optional mute, Optional deaf,
- Optional voice_channel_id, Optional communication_disabled_until, string reason)
- => this.ApiClient.ModifyGuildMemberAsync(guild_id, user_id, nick, role_ids, mute, deaf, voice_channel_id, communication_disabled_until, reason);
-
- ///
- /// Modifies a member
- ///
- /// Member ID
- /// Guild ID
- /// Modifications
- ///
- public async Task ModifyAsync(ulong member_id, ulong guild_id, Action action)
- {
- var mdl = new MemberEditModel();
- action(mdl);
+ return new DiscordUser(await this.ApiClient.ModifyCurrentUserAsync(username, av64)) { Discord = this };
+ }
- if (mdl.VoiceChannel.HasValue && mdl.VoiceChannel.Value != null && mdl.VoiceChannel.Value.Type != ChannelType.Voice && mdl.VoiceChannel.Value.Type != ChannelType.Stage)
- throw new ArgumentException("Given channel is not a voice or stage channel.", nameof(mdl.VoiceChannel));
+ ///
+ /// Gets current user's guilds
+ ///
+ /// Limit of guilds to get
+ /// Gets guild before ID
+ /// Gets guilds after ID
+ ///
+ public async Task> GetCurrentUserGuildsAsync(int limit = 100, ulong? before = null, ulong? after = null)
+ => await this.ApiClient.GetCurrentUserGuildsAsync(limit, before, after);
+
+ ///
+ /// Modifies guild member.
+ ///
+ /// Guild ID
+ /// User ID
+ /// New nickname
+ /// New roles
+ /// Whether this user should be muted
+ /// Whether this user should be deafened
+ /// Voice channel to move this user to
+ /// How long this member should be timed out for. Requires MODERATE_MEMBERS permission.
+ /// Reason this user was modified
+ ///
+ public async Task ModifyGuildMemberAsync(ulong guild_id, ulong user_id, Optional nick,
+ Optional> role_ids, Optional mute, Optional