From ec0801d0bc2e6ac3ebdba77e6f538c258bfe1733 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 18 Jul 2021 10:04:24 -0300 Subject: [PATCH] Add emoji and guild endpoints --- src/Models/Channels/Channel.cs | 2 +- src/Models/Guilds/Ban.cs | 10 + src/Models/Guilds/Guild.cs | 30 + src/Models/Guilds/GuildMember.cs | 7 +- src/Models/Invites/Invite.cs | 6 +- src/Rest/DiscordRestClient.cs | 405 ++++++++- src/Rest/Net/IDiscordRestApi.cs | 921 ++++++++++++++++++++- .../Requests/Channels/ModifyGroupChannelParams.cs | 6 +- .../Net/Requests/Emojis/CreateGuildEmojiParams.cs | 33 + .../Net/Requests/Emojis/ModifyGuildEmojiParams.cs | 28 + .../Net/Requests/Guilds/AddGuildMemberParams.cs | 41 + .../Net/Requests/Guilds/BeginGuildPruneParams.cs | 39 + .../Net/Requests/Guilds/CreateGuildBanParams.cs | 29 + .../Requests/Guilds/CreateGuildChannelParams.cs | 83 ++ src/Rest/Net/Requests/Guilds/CreateGuildParams.cs | 75 ++ .../Net/Requests/Guilds/CreateGuildRoleParams.cs | 43 + src/Rest/Net/Requests/Guilds/GetGuildParams.cs | 20 + .../Requests/Guilds/GetGuildPruneCountParams.cs | 30 + .../Net/Requests/Guilds/ListGuildMembersParams.cs | 29 + .../Requests/Guilds/ModifyCurrentUserNickParams.cs | 23 + .../Guilds/ModifyCurrentUserVoiceStateParams.cs | 32 + .../Guilds/ModifyGuildChannelPositionsParams.cs | 35 + .../Net/Requests/Guilds/ModifyGuildMemberParams.cs | 43 + src/Rest/Net/Requests/Guilds/ModifyGuildParams.cs | 115 +++ .../Net/Requests/Guilds/ModifyGuildRoleParams.cs | 41 + .../Guilds/ModifyGuildRolePositionsParams.cs | 25 + .../Guilds/ModifyGuildWelcomeScreenParams.cs | 32 + .../Requests/Guilds/ModifyUserVoiceStateParams.cs | 25 + .../Requests/Guilds/SearchGuildMembersParams.cs | 30 + src/Rest/Net/Requests/Image.cs | 57 ++ src/Rest/Net/Requests/ImageFormat.cs | 25 + src/Rest/Net/Responses/Prune.cs | 17 + 32 files changed, 2310 insertions(+), 27 deletions(-) create mode 100644 src/Rest/Net/Requests/Emojis/CreateGuildEmojiParams.cs create mode 100644 src/Rest/Net/Requests/Emojis/ModifyGuildEmojiParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/AddGuildMemberParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/BeginGuildPruneParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/CreateGuildBanParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/CreateGuildChannelParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/CreateGuildParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/CreateGuildRoleParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/GetGuildParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/GetGuildPruneCountParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ListGuildMembersParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyCurrentUserNickParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyCurrentUserVoiceStateParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildChannelPositionsParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildMemberParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildRoleParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildRolePositionsParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyGuildWelcomeScreenParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/ModifyUserVoiceStateParams.cs create mode 100644 src/Rest/Net/Requests/Guilds/SearchGuildMembersParams.cs create mode 100644 src/Rest/Net/Requests/Image.cs create mode 100644 src/Rest/Net/Requests/ImageFormat.cs create mode 100644 src/Rest/Net/Responses/Prune.cs diff --git a/src/Models/Channels/Channel.cs b/src/Models/Channels/Channel.cs index 4ebf077f2..786b3c60a 100644 --- a/src/Models/Channels/Channel.cs +++ b/src/Models/Channels/Channel.cs @@ -39,7 +39,7 @@ namespace Discord.Net.Models /// /// Maximum langth of a channel topic. /// - public const int MaxRateLimitPerUserDuration = 1024; + public const int MaxRateLimitPerUserDuration = 21600; /// /// Minimum amount of users in channel. diff --git a/src/Models/Guilds/Ban.cs b/src/Models/Guilds/Ban.cs index 06ebfe276..43f82c8f2 100644 --- a/src/Models/Guilds/Ban.cs +++ b/src/Models/Guilds/Ban.cs @@ -11,6 +11,16 @@ namespace Discord.Net.Models public record Ban { /// + /// Minimum amount of days to delete messages when banning. + /// + public const int MinDaysToDeleteMessages = 0; + + /// + /// Maximum amount of days to delete messages when banning. + /// + public const int MaxDaysToDeleteMessages = 7; + + /// /// The reason for the ban. /// [JsonPropertyName("reason")] diff --git a/src/Models/Guilds/Guild.cs b/src/Models/Guilds/Guild.cs index 4eb64b793..a938801e7 100644 --- a/src/Models/Guilds/Guild.cs +++ b/src/Models/Guilds/Guild.cs @@ -12,6 +12,36 @@ namespace Discord.Net.Models public record Guild { /// + /// Minimum langth of a guild name. + /// + public const int MinGuildNameLength = 2; + + /// + /// Maximum langth of a guild name. + /// + public const int MaxGuildNameLength = 100; + + /// + /// Minimum amount of days to prune for. + /// + public const int MinAmountOfDaysToPruneFor = 1; + + /// + /// Maximum amount of days to prune for. + /// + public const int MaxAmountOfDaysToPruneFor = 30; + + /// + /// Minimum limit of users to list. + /// + public const int MinUserLimitToList = 1; + + /// + /// Maximum limit of users to list. + /// + public const int MaxUserLimitToList = 1000; + + /// /// id. /// [JsonPropertyName("id")] diff --git a/src/Models/Guilds/GuildMember.cs b/src/Models/Guilds/GuildMember.cs index f024acb5f..c01da4bfc 100644 --- a/src/Models/Guilds/GuildMember.cs +++ b/src/Models/Guilds/GuildMember.cs @@ -12,13 +12,18 @@ namespace Discord.Net.Models public record GuildMember { /// + /// Maximum langth of a guild member nickname. + /// + public const int MaxNicknameLength = 32; + + /// /// The this represents. /// [JsonPropertyName("user")] public Optional User { get; init; } /// - /// This users nickname. + /// This user's nickname. /// [JsonPropertyName("nick")] public Optional Nick { get; init; } diff --git a/src/Models/Invites/Invite.cs b/src/Models/Invites/Invite.cs index f17d9d44a..17aa468c6 100644 --- a/src/Models/Invites/Invite.cs +++ b/src/Models/Invites/Invite.cs @@ -14,8 +14,12 @@ namespace Discord.Net.Models /// /// The code (unique ID). /// + /// + /// Might be if it is a vanity url invite and + /// it was not set for the . + /// [JsonPropertyName("code")] - public string? Code { get; init; } // Required property candidate + public string? Code { get; init; } /// /// The this is for. diff --git a/src/Rest/DiscordRestClient.cs b/src/Rest/DiscordRestClient.cs index fff0069a2..a3a8cb108 100644 --- a/src/Rest/DiscordRestClient.cs +++ b/src/Rest/DiscordRestClient.cs @@ -41,7 +41,7 @@ namespace Discord.Net #region Channel /// - public Task GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default) + public Task GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); return _api.GetChannelAsync(channelId, cancellationToken); @@ -82,7 +82,7 @@ namespace Discord.Net } /// - public Task GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default) + public Task> GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); Preconditions.NotNull(args, nameof(args)); @@ -91,7 +91,7 @@ namespace Discord.Net } /// - public Task GetChannelMessageAsync(Snowflake channelId, Snowflake messageId, CancellationToken cancellationToken = default) + public Task GetChannelMessageAsync(Snowflake channelId, Snowflake messageId, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); Preconditions.NotZero(messageId, nameof(messageId)); @@ -144,7 +144,7 @@ namespace Discord.Net } /// - public Task GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default) + public Task> GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); Preconditions.NotZero(messageId, nameof(messageId)); @@ -209,7 +209,7 @@ namespace Discord.Net } /// - public Task GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default) + public Task> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); return _api.GetChannelInvitesAsync(channelId, cancellationToken); @@ -249,7 +249,7 @@ namespace Discord.Net } /// - public Task GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default) + public Task> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); return _api.GetPinnedMessagesAsync(channelId, cancellationToken); @@ -339,7 +339,7 @@ namespace Discord.Net } /// - public Task ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default) + public Task> ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default) { Preconditions.NotZero(channelId, nameof(channelId)); return _api.ListThreadMembersAsync(channelId, cancellationToken); @@ -380,5 +380,396 @@ namespace Discord.Net } #endregion Channel + + #region Emoji + + /// + public Task> ListGuildEmojisAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(emoji, nameof(emoji)); + return _api.ListGuildEmojisAsync(guildId, emoji, cancellationToken); + } + + /// + public Task GetGuildEmojiAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(emoji, nameof(emoji)); + return _api.GetGuildEmojiAsync(guildId, emoji, cancellationToken); + } + + /// + public Task CreateGuildEmojiAsync(Snowflake guildId, Emoji emoji, CreateGuildEmojiParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(emoji, nameof(emoji)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.CreateGuildEmojiAsync(guildId, emoji, args, cancellationToken); + } + + /// + public Task ModifyGuildEmojiAsync(Snowflake guildId, Emoji emoji, ModifyGuildEmojiParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(emoji, nameof(emoji)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyGuildEmojiAsync(guildId, emoji, args, cancellationToken); + } + + /// + public Task DeleteGuildEmojiAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(emoji, nameof(emoji)); + return _api.DeleteGuildEmojiAsync(guildId, emoji, cancellationToken); + } + + #endregion Emoji + + #region Guild + + /// + public Task CreateGuildAsync(CreateGuildParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.CreateGuildAsync(args, cancellationToken); + } + + /// + public Task GetGuildAsync(Snowflake guildId, GetGuildParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.GetGuildAsync(guildId, args, cancellationToken); + } + + /// + public Task GetGuildPreviewAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildPreviewAsync(guildId, cancellationToken); + } + + /// + public Task ModifyGuildAsync(Snowflake guildId, ModifyGuildParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyGuildAsync(guildId, args, cancellationToken); + } + + /// + public Task DeleteGuildAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.DeleteGuildAsync(guildId, cancellationToken); + } + + /// + public Task> GetGuildChannelsAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildChannelsAsync(guildId, cancellationToken); + } + + /// + public Task CreateGuildChannelAsync(Snowflake guildId, CreateGuildChannelParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.CreateGuildChannelAsync(guildId, args, cancellationToken); + } + + /// + public Task ModifyGuildChannelPositionsAsync(Snowflake guildId, ModifyGuildChannelPositionsParams[] args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + foreach (var value in args) + { + Preconditions.NotNull(value, nameof(args)); + value.Validate(); + } + return _api.ModifyGuildChannelPositionsAsync(guildId, args, cancellationToken); + } + + /// + public Task GetGuildMemberAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + return _api.GetGuildMemberAsync(guildId, userId, cancellationToken); + } + + /// + public Task> ListGuildMembersAsync(Snowflake guildId, ListGuildMembersParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ListGuildMembersAsync(guildId, args, cancellationToken); + } + + /// + public Task> SearchGuildMembersAsync(Snowflake guildId, SearchGuildMembersParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.SearchGuildMembersAsync(guildId, args, cancellationToken); + } + + /// + public Task AddGuildMemberAsync(Snowflake guildId, Snowflake userId, AddGuildMemberParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.AddGuildMemberAsync(guildId, userId, args, cancellationToken); + } + + /// + public Task ModifyGuildMemberAsync(Snowflake guildId, Snowflake userId, ModifyGuildMemberParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyGuildMemberAsync(guildId, userId, args, cancellationToken); + } + + /// + public Task ModifyCurrentUserNickAsync(Snowflake guildId, ModifyCurrentUserNickParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyCurrentUserNickAsync(guildId, args, cancellationToken); + } + + /// + public Task AddGuildMemberRoleAsync(Snowflake guildId, Snowflake userId, Snowflake roleId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotZero(roleId, nameof(roleId)); + return _api.AddGuildMemberRoleAsync(guildId, userId, roleId, cancellationToken); + } + + /// + public Task RemoveGuildMemberRoleAsync(Snowflake guildId, Snowflake userId, Snowflake roleId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotZero(roleId, nameof(roleId)); + return _api.RemoveGuildMemberRoleAsync(guildId, userId, roleId, cancellationToken); + } + + /// + public Task RemoveGuildMemberAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + return _api.RemoveGuildMemberAsync(guildId, userId, cancellationToken); + } + + /// + public Task> GetGuildBansAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildBansAsync(guildId, cancellationToken); + } + + /// + public Task GetGuildBanAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + return _api.GetGuildBanAsync(guildId, userId, cancellationToken); + } + + /// + public Task CreateGuildBanAsync(Snowflake guildId, Snowflake userId, CreateGuildBanParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.CreateGuildBanAsync(guildId, userId, args, cancellationToken); + } + + /// + public Task RemoveGuildBanAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + return _api.RemoveGuildBanAsync(guildId, userId, cancellationToken); + } + + /// + public Task> GetGuildRolesAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildRolesAsync(guildId, cancellationToken); + } + + /// + public Task CreateGuildRoleAsync(Snowflake guildId, CreateGuildRoleParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.CreateGuildRoleAsync(guildId, args, cancellationToken); + } + + /// + public Task> ModifyGuildRolePositionsAsync(Snowflake guildId, ModifyGuildRolePositionsParams[] args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + foreach (var value in args) + { + Preconditions.NotNull(value, nameof(args)); + value.Validate(); + } + return _api.ModifyGuildRolePositionsAsync(guildId, args, cancellationToken); + } + + /// + public Task ModifyGuildRoleAsync(Snowflake guildId, Snowflake roleId, ModifyGuildRoleParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(roleId, nameof(roleId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyGuildRoleAsync(guildId, roleId, args, cancellationToken); + } + + /// + public Task DeleteGuildRoleAsync(Snowflake guildId, Snowflake roleId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(roleId, nameof(roleId)); + return _api.DeleteGuildRoleAsync(guildId, roleId, cancellationToken); + } + + /// + public Task GetGuildPruneCountAsync(Snowflake guildId, GetGuildPruneCountParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.GetGuildPruneCountAsync(guildId, args, cancellationToken); + } + + /// + public Task BeginGuildPruneAsync(Snowflake guildId, BeginGuildPruneParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.BeginGuildPruneAsync(guildId, args, cancellationToken); + } + + /// + public Task> GetGuildVoiceRegionsAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildVoiceRegionsAsync(guildId, cancellationToken); + } + + /// + public Task> GetGuildInvitesAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildInvitesAsync(guildId, cancellationToken); + } + + /// + public Task> GetGuildIntegrationsAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildIntegrationsAsync(guildId, cancellationToken); + } + + /// + public Task DeleteGuildIntegrationAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.DeleteGuildIntegrationAsync(guildId, cancellationToken); + } + + /// + public Task GetGuildWidgetSettingsAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildWidgetSettingsAsync(guildId, cancellationToken); + } + + /// + public Task ModifyGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.ModifyGuildWidgetAsync(guildId, cancellationToken); + } + + /// + public Task GetGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildWidgetAsync(guildId, cancellationToken); + } + + /// + public Task GetGuildVanityURLAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildVanityURLAsync(guildId, cancellationToken); + } + + /// + public Task GetGuildWelcomeScreenAsync(Snowflake guildId, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + return _api.GetGuildWelcomeScreenAsync(guildId, cancellationToken); + } + + /// + public Task ModifyGuildWelcomeScreenAsync(Snowflake guildId, ModifyGuildWelcomeScreenParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyGuildWelcomeScreenAsync(guildId, args, cancellationToken); + } + + /// + public Task ModifyCurrentUserVoiceStateAsync(Snowflake guildId, ModifyCurrentUserVoiceStateParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyCurrentUserVoiceStateAsync(guildId, args, cancellationToken); + } + + /// + public Task ModifyUserVoiceStateAsync(Snowflake guildId, Snowflake userId, ModifyUserVoiceStateParams args, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + Preconditions.NotZero(userId, nameof(userId)); + Preconditions.NotNull(args, nameof(args)); + args.Validate(); + return _api.ModifyUserVoiceStateAsync(guildId, userId, args, cancellationToken); + } + + #endregion Guild } } diff --git a/src/Rest/Net/IDiscordRestApi.cs b/src/Rest/Net/IDiscordRestApi.cs index b980561a8..a84933fc3 100644 --- a/src/Rest/Net/IDiscordRestApi.cs +++ b/src/Rest/Net/IDiscordRestApi.cs @@ -1,7 +1,4 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Discord.Net.Models; @@ -52,7 +49,7 @@ namespace Discord.Net.Rest /// A task that contains a if it exists; /// otherwise, . /// - Task GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default); + Task GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default); /// /// Updates a 's settings. @@ -141,7 +138,7 @@ namespace Discord.Net.Rest Task DeleteChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default); /// - /// Gets an array of s from a . + /// Gets all specified s from a . /// /// /// @@ -158,7 +155,7 @@ namespace Discord.Net.Rest /// /// A task that contains an array of s from the . /// - Task GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default); + Task> GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default); /// /// Gets a specific from a . @@ -178,7 +175,7 @@ namespace Discord.Net.Rest /// /// A task that contains the specified or . /// - Task GetChannelMessageAsync(Snowflake channelId, Snowflake messageId, CancellationToken cancellationToken = default); + Task GetChannelMessageAsync(Snowflake channelId, Snowflake messageId, CancellationToken cancellationToken = default); /// /// Sends a to a . @@ -293,7 +290,7 @@ namespace Discord.Net.Rest Task DeleteUserReactionAsync(Snowflake channelId, Snowflake messageId, Snowflake userId, Emoji emoji, CancellationToken cancellationToken = default); /// - /// Gets an array of s that reacted with this . + /// Gets all s that reacted with this . /// /// /// @@ -317,7 +314,7 @@ namespace Discord.Net.Rest /// A task that contains an array of s that reacted with /// the provided . /// - Task GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default); + Task> GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default); /// /// Deletes all s on a . @@ -453,7 +450,7 @@ namespace Discord.Net.Rest Task EditChannelPermissionsAsync(Snowflake channelId, Snowflake overwriteId, EditChannelPermissionsParams args, CancellationToken cancellationToken = default); /// - /// Gets an array of s for a . + /// Gets all s for a . /// /// /// @@ -467,7 +464,7 @@ namespace Discord.Net.Rest /// /// A task that contains an array of s. /// - Task GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default); + Task> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default); /// /// Creates a new for the . @@ -558,7 +555,7 @@ namespace Discord.Net.Rest /// /// A task that contains an array of all pinned s. /// - Task GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default); + Task> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default); /// /// Pins a in a . @@ -767,7 +764,7 @@ namespace Discord.Net.Rest Task RemoveThreadMemberAsync(Snowflake channelId, Snowflake userId, CancellationToken cancellationToken = default); /// - /// Gets an array of s that are part of the . + /// Gets all s that are part of the . /// /// /// @@ -782,7 +779,7 @@ namespace Discord.Net.Rest /// A task that contains an array of s that are part of the /// specified . /// - Task ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default); + Task> ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default); /// /// Gets all active s in the . @@ -864,6 +861,902 @@ namespace Discord.Net.Rest #endregion Channel + #region Emoji + /// + /// Gets all s for the given . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// An . + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains an array of s. + /// + Task> ListGuildEmojisAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default); + + /// + /// Gets an for the given and IDs. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// An . + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains an . + /// + Task GetGuildEmojiAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default); + + /// + /// Creates a new for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// An . + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the created . + /// + /// + /// Thrown when invalid parameters are supplied in . + /// + Task CreateGuildEmojiAsync(Snowflake guildId, Emoji emoji, CreateGuildEmojiParams args, CancellationToken cancellationToken = default); + + /// + /// Modify the given . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// An . + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildEmojiAsync(Snowflake guildId, Emoji emoji, ModifyGuildEmojiParams args, CancellationToken cancellationToken = default); + + /// + /// Delete the given . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// An . + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task DeleteGuildEmojiAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default); + + #endregion Emoji + + #region Guild + + /// + /// Creates a new . + /// + /// + /// + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the created . + /// + Task CreateGuildAsync(CreateGuildParams args, CancellationToken cancellationToken = default); + + /// + /// Gets a for the given id. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the requested if it exists; or . + /// + Task GetGuildAsync(Snowflake guildId, GetGuildParams args, CancellationToken cancellationToken = default); + + /// + /// Gets the preview for the given id. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the requested preview if it exists and is + /// viewable; or . + /// + Task GetGuildPreviewAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Modifies a 's settings. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildAsync(Snowflake guildId, ModifyGuildParams args, CancellationToken cancellationToken = default); + + /// + /// Deletes a permanently. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task DeleteGuildAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets all s. It does not include s. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildChannelsAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Creates a new for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the created . + /// + Task CreateGuildChannelAsync(Snowflake guildId, CreateGuildChannelParams args, CancellationToken cancellationToken = default); + + /// + /// Modifies the positions of a set of s for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task ModifyGuildChannelPositionsAsync(Snowflake guildId, ModifyGuildChannelPositionsParams[] args, CancellationToken cancellationToken = default); + + /// + /// Gets a specified . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the requested ; or if not found. + /// + Task GetGuildMemberAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default); + + /// + /// Gets a collection of that are members of the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the returned collection of s. + /// + Task> ListGuildMembersAsync(Snowflake guildId, ListGuildMembersParams args, CancellationToken cancellationToken = default); + + /// + /// Gets a collection of s whose username or nickname starts with a provided string. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the returned collection of s. + /// + Task> SearchGuildMembersAsync(Snowflake guildId, SearchGuildMembersParams args, CancellationToken cancellationToken = default); + + /// + /// Adds a to the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the related to the provided ; + /// or if they are already a part of the . + /// + /// + /// Thrown when invalid parameters are supplied in . + /// + Task AddGuildMemberAsync(Snowflake guildId, Snowflake userId, AddGuildMemberParams args, CancellationToken cancellationToken = default); + + /// + /// Modifies attributes of a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildMemberAsync(Snowflake guildId, Snowflake userId, ModifyGuildMemberParams args, CancellationToken cancellationToken = default); + + /// + /// Modifies the nickname of the current user in a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated nickname. + /// + Task ModifyCurrentUserNickAsync(Snowflake guildId, ModifyCurrentUserNickParams args, CancellationToken cancellationToken = default); + + /// + /// Adds a to a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task AddGuildMemberRoleAsync(Snowflake guildId, Snowflake userId, Snowflake roleId, CancellationToken cancellationToken = default); + + /// + /// Removes a from a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task RemoveGuildMemberRoleAsync(Snowflake guildId, Snowflake userId, Snowflake roleId, CancellationToken cancellationToken = default); + + /// + /// Removes a from a . + /// + /// + /// + /// + /// + /// The The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task RemoveGuildMemberAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default); + + /// + /// Gets a collection of s for the users banned from this . + /// + /// + /// + /// + /// + /// The The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildBansAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets a for the given . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the ; or if not found. + /// + Task GetGuildBanAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default); + + /// + /// Creates a guild , and optionally delete previous messages sent by the banned . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task CreateGuildBanAsync(Snowflake guildId, Snowflake userId, CreateGuildBanParams args, CancellationToken cancellationToken = default); + + /// + /// Removes the for a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task RemoveGuildBanAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default); + + /// + /// Gets all s for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildRolesAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Creates a new for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the created . + /// + Task CreateGuildRoleAsync(Snowflake guildId, CreateGuildRoleParams args, CancellationToken cancellationToken = default); + + /// + /// Modifies the positions of a set of s for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> ModifyGuildRolePositionsAsync(Snowflake guildId, ModifyGuildRolePositionsParams[] args, CancellationToken cancellationToken = default); + + /// + /// Modifies a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildRoleAsync(Snowflake guildId, Snowflake roleId, ModifyGuildRoleParams args, CancellationToken cancellationToken = default); + + /// + /// Deletes a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task DeleteGuildRoleAsync(Snowflake guildId, Snowflake roleId, CancellationToken cancellationToken = default); + + /// + /// Gets a with the number of members that would be removed in a prune operation. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the a with the number of members that would be removed in a prune operation. + /// + Task GetGuildPruneCountAsync(Snowflake guildId, GetGuildPruneCountParams args, CancellationToken cancellationToken = default); + + /// + /// Begins a prune operation. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the a with the number of members that were removed in the prune operation. + /// + Task BeginGuildPruneAsync(Snowflake guildId, BeginGuildPruneParams args, CancellationToken cancellationToken = default); + + /// + /// Gets all s for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildVoiceRegionsAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets all for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildInvitesAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets all s for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a collection of s. + /// + Task> GetGuildIntegrationsAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Deletes the attached for the . + /// Deletes any associated s and kicks the associated bot if there is one. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task DeleteGuildIntegrationAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets a . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a . + /// + Task GetGuildWidgetSettingsAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Modifies a for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + // TODO: Create a Widget object or remove this? + /// + /// Gets the widget for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the widget for the . + /// + Task GetGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets a partial for s with a vanity url enabled. + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a partial if the has + /// this feature enabled; or otherwise. + /// + Task GetGuildVanityURLAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Gets the for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains a . + /// + Task GetGuildWelcomeScreenAsync(Snowflake guildId, CancellationToken cancellationToken = default); + + /// + /// Modifies the for the . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that contains the updated . + /// + Task ModifyGuildWelcomeScreenAsync(Snowflake guildId, ModifyGuildWelcomeScreenParams args, CancellationToken cancellationToken = default); + + /// + /// Updates the current user's . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task ModifyCurrentUserVoiceStateAsync(Snowflake guildId, ModifyCurrentUserVoiceStateParams args, CancellationToken cancellationToken = default); + + /// + /// Updates another user's . + /// + /// + /// + /// + /// + /// The identifier. + /// + /// + /// The identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + /// + /// A task that represents this asynchronous operation. + /// + Task ModifyUserVoiceStateAsync(Snowflake guildId, Snowflake userId, ModifyUserVoiceStateParams args, CancellationToken cancellationToken = default); + + #endregion Guild } } diff --git a/src/Rest/Net/Requests/Channels/ModifyGroupChannelParams.cs b/src/Rest/Net/Requests/Channels/ModifyGroupChannelParams.cs index 5c8b04d5c..09a180511 100644 --- a/src/Rest/Net/Requests/Channels/ModifyGroupChannelParams.cs +++ b/src/Rest/Net/Requests/Channels/ModifyGroupChannelParams.cs @@ -11,14 +11,14 @@ namespace Discord.Net.Rest public record ModifyGroupChannelParams { /// - /// name. + /// name. /// public Optional Name { get; set; } /// - /// Base64 encoded icon. + /// icon. /// - public Optional Icon { get; set; } + public Optional Icon { get; set; } /// /// Validates the data. diff --git a/src/Rest/Net/Requests/Emojis/CreateGuildEmojiParams.cs b/src/Rest/Net/Requests/Emojis/CreateGuildEmojiParams.cs new file mode 100644 index 000000000..d6e58bdf2 --- /dev/null +++ b/src/Rest/Net/Requests/Emojis/CreateGuildEmojiParams.cs @@ -0,0 +1,33 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record CreateGuildEmojiParams + { + /// + /// Name of the . + /// + public string? Name { get; set; } // Required property candidate + + /// + /// The 128x128 image. + /// + public Image Image { get; set; } + + /// + /// s allowed to use this . + /// + public Snowflake[]? Roles { get; set; } // Required property candidate + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNullOrWhitespace(Name, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Emojis/ModifyGuildEmojiParams.cs b/src/Rest/Net/Requests/Emojis/ModifyGuildEmojiParams.cs new file mode 100644 index 000000000..8c4a94954 --- /dev/null +++ b/src/Rest/Net/Requests/Emojis/ModifyGuildEmojiParams.cs @@ -0,0 +1,28 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildEmojiParams + { + /// + /// Name of the . + /// + public Optional Name { get; set; } + + /// + /// s allowed to use this . + /// + public Optional Roles { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNullOrWhitespace(Name!, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/AddGuildMemberParams.cs b/src/Rest/Net/Requests/Guilds/AddGuildMemberParams.cs new file mode 100644 index 000000000..68cdf640f --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/AddGuildMemberParams.cs @@ -0,0 +1,41 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record AddGuildMemberParams + { + /// + /// An oauth2 access token granted with the guilds.join to the bot's application for the user you want to add to the guild. + /// + public string? AccessToken { get; set; } // Required property candidate + + /// + /// Value to set users nickname to. + /// + public Optional Nick { get; set; } + + /// + /// Array of role ids the member is assigned. + /// + public Optional Roles { get; set; } + + /// + /// Whether the user is muted in voice channels. + /// + public Optional Mute { get; set; } + + /// + /// Whether the user is deafened in voice channels. + /// + public Optional Deaf { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNullOrEmpty(AccessToken, nameof(AccessToken)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/BeginGuildPruneParams.cs b/src/Rest/Net/Requests/Guilds/BeginGuildPruneParams.cs new file mode 100644 index 000000000..e029df7c9 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/BeginGuildPruneParams.cs @@ -0,0 +1,39 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record BeginGuildPruneParams + { + /// + /// Number of days to prune (1-30). + /// + public Optional Days { get; set; } + + /// + /// Whether 'pruned' is returned, discouraged for large guilds. + /// + public Optional ComputePruneCount { get; set; } + + /// + /// Role(s) to include, by id. + /// + public Optional IncludeRoles { get; set; } + + /// + /// Reason for the prune. + /// + public Optional Reason { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.AtLeast(Days, Guild.MinAmountOfDaysToPruneFor, nameof(Days)); + Preconditions.AtMost(Days, Guild.MaxAmountOfDaysToPruneFor, nameof(Days)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/CreateGuildBanParams.cs b/src/Rest/Net/Requests/Guilds/CreateGuildBanParams.cs new file mode 100644 index 000000000..fb488d754 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/CreateGuildBanParams.cs @@ -0,0 +1,29 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record CreateGuildBanParams + { + /// + /// Number of days to delete messages for (0-7). + /// + public Optional DeleteMessageDays { get; set; } + + /// + /// Reason for the ban. + /// + public Optional Reason { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.AtLeast(DeleteMessageDays, Ban.MinDaysToDeleteMessages, nameof(DeleteMessageDays)); + Preconditions.AtMost(DeleteMessageDays, Ban.MaxDaysToDeleteMessages, nameof(DeleteMessageDays)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/CreateGuildChannelParams.cs b/src/Rest/Net/Requests/Guilds/CreateGuildChannelParams.cs new file mode 100644 index 000000000..4137b5a79 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/CreateGuildChannelParams.cs @@ -0,0 +1,83 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record CreateGuildChannelParams + { + /// + /// Channel name (1-100 characters). + /// + public string? Name { get; set; } // Required property candidate + + /// + /// The type of channel. + /// + public Optional Type { get; set; } + + /// + /// Channel topic (0-1024 characters). + /// + public Optional Topic { get; set; } + + /// + /// The bitrate (in bits) of the voice channel (voice only). + /// + public Optional Bitrate { get; set; } + + /// + /// The user limit of the voice channel (voice only). + /// + public Optional UserLimit { get; set; } + + /// + /// Amount of seconds a user has to wait before sending another message (0-21600); + /// bots, as well as users with the permission or + /// , are unaffected. + /// + public Optional RateLimitPerUser { get; set; } + + /// + /// Sorting position of the channel. + /// + public Optional Position { get; set; } + + /// + /// The channel's permission overwrites. + /// + public Optional PermissionOverwrites { get; set; } + + /// + /// Id of the parent category for a channel. + /// + public Optional ParentId { get; set; } + + /// + /// Whether the channel is nsfw. + /// + public Optional Nsfw { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNull(Name, nameof(Name)); + Preconditions.LengthAtLeast(Name, Channel.MinChannelNameLength, nameof(Name)); + Preconditions.LengthAtMost(Name, Channel.MaxChannelNameLength, nameof(Name)); + Preconditions.NotNegative(Position, nameof(Position)); + Preconditions.NotNull(Topic!, nameof(Topic)); + Preconditions.LengthAtLeast(Topic!, Channel.MinChannelTopicLength, nameof(Topic)); + Preconditions.LengthAtMost(Topic!, Channel.MaxChannelTopicLength, nameof(Topic)); + Preconditions.AtLeast(RateLimitPerUser, Channel.MinRateLimitPerUserDuration, nameof(RateLimitPerUser)); + Preconditions.AtMost(RateLimitPerUser, Channel.MaxRateLimitPerUserDuration, nameof(RateLimitPerUser)); + Preconditions.AtLeast(Bitrate, Channel.MinBitrate, nameof(Bitrate)); + Preconditions.AtMost(Bitrate, Channel.MaxBitrate, nameof(Bitrate)); + Preconditions.AtLeast(UserLimit, Channel.MinUserLimit, nameof(UserLimit)); + Preconditions.AtMost(UserLimit, Channel.MaxUserLimit, nameof(UserLimit)); + Preconditions.NotNull(PermissionOverwrites!, nameof(PermissionOverwrites)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/CreateGuildParams.cs b/src/Rest/Net/Requests/Guilds/CreateGuildParams.cs new file mode 100644 index 000000000..2744e9460 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/CreateGuildParams.cs @@ -0,0 +1,75 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record CreateGuildParams + { + /// + /// Name of the guild (2-100 characters). + /// + public string? Name { get; set; } // Required property candidate + + /// + /// Image for the guild icon. + /// + public Optional Icon { get; set; } + + /// + /// Verification level. + /// + public Optional VerificationLevel { get; set; } + + /// + /// Default message notification level. + /// + public Optional DefaultMessageNotifications { get; set; } + + /// + /// Explicit content filter level. + /// + public Optional ExplicitContentFilter { get; set; } + + /// + /// New guild roles. + /// + public Optional Roles { get; set; } + + /// + /// New guild's channels. + /// + public Optional Channels { get; set; } + + /// + /// Id for afk channel. + /// + public Optional AfkChannelId { get; set; } + + /// + /// Afk timeout in seconds. + /// + public Optional AfkTimeout { get; set; } + + /// + /// The id of the channel where guild notices such as welcome messages and boost events are posted. + /// + public Optional SystemChannelId { get; set; } + + /// + /// System channel flags. + /// + public Optional SystemChannelFlags { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNull(Name, nameof(Name)); + Preconditions.LengthAtLeast(Name, Guild.MinGuildNameLength, nameof(Name)); + Preconditions.LengthAtMost(Name, Guild.MaxGuildNameLength, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/CreateGuildRoleParams.cs b/src/Rest/Net/Requests/Guilds/CreateGuildRoleParams.cs new file mode 100644 index 000000000..cd102ff1a --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/CreateGuildRoleParams.cs @@ -0,0 +1,43 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record CreateGuildRoleParams + { + /// + /// Name of the role. + /// + public Optional Name { get; set; } + + /// + /// Bitwise value of the enabled/disabled permissions. + /// + public Optional Permissions { get; set; } + + /// + /// Role color. + /// + public Optional Color { get; set; } + + /// + /// Whether the role should be displayed separately in the sidebar. + /// + public Optional Hoist { get; set; } + + /// + /// Whether the role should be mentionable. + /// + public Optional Mentionable { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNullOrEmpty(Name!, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/GetGuildParams.cs b/src/Rest/Net/Requests/Guilds/GetGuildParams.cs new file mode 100644 index 000000000..8f2690e39 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/GetGuildParams.cs @@ -0,0 +1,20 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record GetGuildParams + { + /// + /// When true, will return approximate member and presence counts for the guild. + /// + public Optional WithCounts { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/GetGuildPruneCountParams.cs b/src/Rest/Net/Requests/Guilds/GetGuildPruneCountParams.cs new file mode 100644 index 000000000..d1d0333bf --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/GetGuildPruneCountParams.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record GetGuildPruneCountParams + { + /// + /// Number of days to count prune for (1-30). + /// + public Optional Days { get; set; } + + /// + /// Role(s) to include, by id. + /// + public Optional> IncludeRoles { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.AtLeast(Days, Guild.MinAmountOfDaysToPruneFor, nameof(Days)); + Preconditions.AtMost(Days, Guild.MaxAmountOfDaysToPruneFor, nameof(Days)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ListGuildMembersParams.cs b/src/Rest/Net/Requests/Guilds/ListGuildMembersParams.cs new file mode 100644 index 000000000..edfd99b84 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ListGuildMembersParams.cs @@ -0,0 +1,29 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ListGuildMembersParams + { + /// + /// Max number of members to return (1-1000). + /// + public int Limit { get; set; } + + /// + /// The highest user id in the previous page. + /// + public Snowflake After { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.AtLeast(Limit, Guild.MinUserLimitToList, nameof(Limit)); + Preconditions.AtMost(Limit, Guild.MaxUserLimitToList, nameof(Limit)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyCurrentUserNickParams.cs b/src/Rest/Net/Requests/Guilds/ModifyCurrentUserNickParams.cs new file mode 100644 index 000000000..1d94e7dd6 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyCurrentUserNickParams.cs @@ -0,0 +1,23 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyCurrentUserNickParams + { + /// + /// Value to set users nickname to. + /// + public Optional Nick { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.LengthAtMost(Nick, GuildMember.MaxNicknameLength, nameof(Nick)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyCurrentUserVoiceStateParams.cs b/src/Rest/Net/Requests/Guilds/ModifyCurrentUserVoiceStateParams.cs new file mode 100644 index 000000000..96aa1049d --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyCurrentUserVoiceStateParams.cs @@ -0,0 +1,32 @@ +using System; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyCurrentUserVoiceStateParams + { + /// + /// The id of the channel the user is currently in. + /// + public Snowflake ChannelId { get; set; } + + /// + /// Toggles the user's suppress state. + /// + public Optional Suppress { get; set; } + + /// + /// Sets the user's request to speak. + /// + public Optional RequestToSpeakTimestamp { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildChannelPositionsParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildChannelPositionsParams.cs new file mode 100644 index 000000000..9ef0c39b7 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildChannelPositionsParams.cs @@ -0,0 +1,35 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildChannelPositionsParams + { + /// + /// Channel id. + /// + public Snowflake Id { get; set; } + + /// + /// Sorting position of the channel. + /// + public int? Position { get; set; } + + /// + /// Syncs the permission overwrites with the new parent, if moving to a new category. + /// + public bool? LockPermissions { get; set; } + + /// + /// The new parent ID for the channel that is moved. + /// + public Snowflake? ParentId { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildMemberParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildMemberParams.cs new file mode 100644 index 000000000..e70219788 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildMemberParams.cs @@ -0,0 +1,43 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildMemberParams + { + /// + /// Value to set users nickname to. + /// + public Optional Nick { get; set; } + + /// + /// Array of role ids the member is assigned. + /// + public Optional Roles { get; set; } + + /// + /// Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel. + /// + public Optional Mute { get; set; } + + /// + /// Whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel. + /// + public Optional Deaf { get; set; } + + /// + /// Id of channel to move user to (if they are connected to voice). + /// + public Optional ChannelId { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.LengthAtMost(Nick, GuildMember.MaxNicknameLength, nameof(Nick)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildParams.cs new file mode 100644 index 000000000..a4fb53d55 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildParams.cs @@ -0,0 +1,115 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildParams + { + /// + /// Guild name. + /// + public Optional Name { get; set; } + + /// + /// Guild voice region id (deprecated). + /// + public Optional Region { get; set; } + + /// + /// Verification level. + /// + public Optional VerificationLevel { get; set; } + + /// + /// Default message notification level. + /// + public Optional DefaultMessageNotifications { get; set; } + + /// + /// Explicit content filter level. + /// + public Optional ExplicitContentFilter { get; set; } + + /// + /// Id for afk channel. + /// + public Optional AfkChannelId { get; set; } + + /// + /// Afk timeout in seconds. + /// + public Optional AfkTimeout { get; set; } + + /// + /// Image for the guild icon (can be animated gif when the server has the ANIMATED_ICON feature). + /// + public Optional Icon { get; set; } + + /// + /// User id to transfer guild ownership to (must be owner). + /// + public Optional OwnerId { get; set; } + + /// + /// Image for the guild splash (when the server has the INVITE_SPLASH feature). + /// + public Optional Splash { get; set; } + + /// + /// Image for the guild discovery splash (when the server has the DISCOVERABLE feature). + /// + public Optional DiscoverySplash { get; set; } + + /// + /// Image for the guild banner (when the server has the BANNER feature). + /// + public Optional Banner { get; set; } + + /// + /// The id of the channel where guild notices such as welcome messages and boost events are posted. + /// + public Optional SystemChannelId { get; set; } + + /// + /// System channel flags. + /// + public Optional SystemChannelFlags { get; set; } + + /// + /// The id of the channel where Community guilds display rules and/or guidelines. + /// + public Optional RulesChannelId { get; set; } + + /// + /// The id of the channel where admins and moderators of Community guilds receive notices from Discord. + /// + public Optional PublicUpdatesChannelId { get; set; } + + /// + /// The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US". + /// + public Optional PreferredLocale { get; set; } + + /// + /// Enabled guild features. + /// + public Optional Features { get; set; } + + /// + /// The description for the guild, if the guild is discoverable. + /// + public Optional Description { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNull(Name!, nameof(Name)); + Preconditions.LengthAtLeast(Name!, Guild.MinGuildNameLength, nameof(Name)); + Preconditions.LengthAtMost(Name!, Guild.MaxGuildNameLength, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildRoleParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildRoleParams.cs new file mode 100644 index 000000000..354c3534d --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildRoleParams.cs @@ -0,0 +1,41 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildRoleParams + { + /// + /// Name of the role. + /// + public Optional Name { get; set; } + + /// + /// Bitwise value of the enabled/disabled permissions. + /// + public Optional Permissions { get; set; } + + /// + /// RGB color value. + /// + public Optional Color { get; set; } + + /// + /// Whether the role should be displayed separately in the sidebar. + /// + public Optional Hoist { get; set; } + + /// + /// Whether the role should be mentionable. + /// + public Optional Mentionable { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNullOrEmpty(Name!, nameof(Name)); + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildRolePositionsParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildRolePositionsParams.cs new file mode 100644 index 000000000..9b7fa9be7 --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildRolePositionsParams.cs @@ -0,0 +1,25 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildRolePositionsParams + { + /// + /// Role. + /// + public Snowflake Id { get; set; } + + /// + /// Sorting position of the role. + /// + public Optional Position { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyGuildWelcomeScreenParams.cs b/src/Rest/Net/Requests/Guilds/ModifyGuildWelcomeScreenParams.cs new file mode 100644 index 000000000..9ac2285fb --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyGuildWelcomeScreenParams.cs @@ -0,0 +1,32 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyGuildWelcomeScreenParams + { + /// + /// Whether the welcome screen is enabled. + /// + public Optional Enabled { get; set; } + + /// + /// Channels linked in the welcome screen and their display options. + /// + public Optional WelcomeChannels { get; set; } + + /// + /// The server description to show in the welcome screen. + /// + public Optional Description { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/ModifyUserVoiceStateParams.cs b/src/Rest/Net/Requests/Guilds/ModifyUserVoiceStateParams.cs new file mode 100644 index 000000000..ca583813c --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/ModifyUserVoiceStateParams.cs @@ -0,0 +1,25 @@ +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record ModifyUserVoiceStateParams + { + /// + /// The id of the channel the user is currently in. + /// + public Snowflake ChannelId { get; set; } + + /// + /// Toggles the user's suppress state. + /// + public Optional Suppress { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + } + } +} diff --git a/src/Rest/Net/Requests/Guilds/SearchGuildMembersParams.cs b/src/Rest/Net/Requests/Guilds/SearchGuildMembersParams.cs new file mode 100644 index 000000000..479d0582c --- /dev/null +++ b/src/Rest/Net/Requests/Guilds/SearchGuildMembersParams.cs @@ -0,0 +1,30 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record SearchGuildMembersParams + { + /// + /// Query string to match username(s) and nickname(s) against. + /// + public string? Query { get; set; } // Required property candidate + + /// + /// Max number of members to return (1-1000). + /// + public Optional Limit { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotNull(Query, nameof(Query)); + Preconditions.AtLeast(Limit, Guild.MinUserLimitToList, nameof(Limit)); + Preconditions.AtMost(Limit, Guild.MaxUserLimitToList, nameof(Limit)); + } + } +} diff --git a/src/Rest/Net/Requests/Image.cs b/src/Rest/Net/Requests/Image.cs new file mode 100644 index 000000000..91a3b4433 --- /dev/null +++ b/src/Rest/Net/Requests/Image.cs @@ -0,0 +1,57 @@ +using System.IO; + +namespace Discord.Net.Rest +{ + /// + /// Container to send a base64 encoded image to Discord. + /// + /// + /// + /// + public struct Image + { + /// + /// The image stream. + /// + public Stream? Stream { get; } + + /// + /// The format of the image. + /// + public ImageFormat StreamFormat { get; } + + /// + /// The image hash. + /// + public string? Hash { get; } + + /// + /// Creates an based on a . + /// + /// + /// Image stream. + /// + /// + /// Image format. + /// + public Image(Stream stream, ImageFormat format) + { + Stream = stream; + StreamFormat = format; + Hash = null; + } + + /// + /// Creates an based on the image hash. + /// + /// + /// Image hash. + /// + public Image(string hash) + { + Stream = null; + StreamFormat = ImageFormat.Jpeg; + Hash = hash; + } + } +} diff --git a/src/Rest/Net/Requests/ImageFormat.cs b/src/Rest/Net/Requests/ImageFormat.cs new file mode 100644 index 000000000..7bb6a915a --- /dev/null +++ b/src/Rest/Net/Requests/ImageFormat.cs @@ -0,0 +1,25 @@ +namespace Discord.Net.Rest +{ + /// + /// Declares an enum which represents the format of the image. + /// + public enum ImageFormat + { + /// + /// The image format is WebP. + /// + WebP, + /// + /// The image format is Png. + /// + Png, + /// + /// The image format is Jpg/Jpeg. + /// + Jpeg, + /// + /// The image format is Gif. + /// + Gif, + } +} diff --git a/src/Rest/Net/Responses/Prune.cs b/src/Rest/Net/Responses/Prune.cs new file mode 100644 index 000000000..6c86038f4 --- /dev/null +++ b/src/Rest/Net/Responses/Prune.cs @@ -0,0 +1,17 @@ +namespace Discord.Net.Rest +{ + /// + /// Response to count or begin a prune. + /// + /// + /// or + /// + /// + public record Prune + { + /// + /// Gets the number of members that would or were affected in a prune operation. + /// + public Optional Pruned { get; init; } + } +}