@@ -39,7 +39,7 @@ namespace Discord.Net.Models | |||
/// <summary> | |||
/// Maximum langth of a channel topic. | |||
/// </summary> | |||
public const int MaxRateLimitPerUserDuration = 1024; | |||
public const int MaxRateLimitPerUserDuration = 21600; | |||
/// <summary> | |||
/// Minimum amount of users in channel. | |||
@@ -11,6 +11,16 @@ namespace Discord.Net.Models | |||
public record Ban | |||
{ | |||
/// <summary> | |||
/// Minimum amount of days to delete messages when banning. | |||
/// </summary> | |||
public const int MinDaysToDeleteMessages = 0; | |||
/// <summary> | |||
/// Maximum amount of days to delete messages when banning. | |||
/// </summary> | |||
public const int MaxDaysToDeleteMessages = 7; | |||
/// <summary> | |||
/// The reason for the ban. | |||
/// </summary> | |||
[JsonPropertyName("reason")] | |||
@@ -12,6 +12,36 @@ namespace Discord.Net.Models | |||
public record Guild | |||
{ | |||
/// <summary> | |||
/// Minimum langth of a guild name. | |||
/// </summary> | |||
public const int MinGuildNameLength = 2; | |||
/// <summary> | |||
/// Maximum langth of a guild name. | |||
/// </summary> | |||
public const int MaxGuildNameLength = 100; | |||
/// <summary> | |||
/// Minimum amount of days to prune for. | |||
/// </summary> | |||
public const int MinAmountOfDaysToPruneFor = 1; | |||
/// <summary> | |||
/// Maximum amount of days to prune for. | |||
/// </summary> | |||
public const int MaxAmountOfDaysToPruneFor = 30; | |||
/// <summary> | |||
/// Minimum limit of users to list. | |||
/// </summary> | |||
public const int MinUserLimitToList = 1; | |||
/// <summary> | |||
/// Maximum limit of users to list. | |||
/// </summary> | |||
public const int MaxUserLimitToList = 1000; | |||
/// <summary> | |||
/// <see cref="Guild"/> id. | |||
/// </summary> | |||
[JsonPropertyName("id")] | |||
@@ -12,13 +12,18 @@ namespace Discord.Net.Models | |||
public record GuildMember | |||
{ | |||
/// <summary> | |||
/// Maximum langth of a guild member nickname. | |||
/// </summary> | |||
public const int MaxNicknameLength = 32; | |||
/// <summary> | |||
/// The <see cref="Models.User"/> this <see cref="GuildMember"/> represents. | |||
/// </summary> | |||
[JsonPropertyName("user")] | |||
public Optional<User> User { get; init; } | |||
/// <summary> | |||
/// This users <see cref="Guild"/> nickname. | |||
/// This user's <see cref="Guild"/> nickname. | |||
/// </summary> | |||
[JsonPropertyName("nick")] | |||
public Optional<string?> Nick { get; init; } | |||
@@ -14,8 +14,12 @@ namespace Discord.Net.Models | |||
/// <summary> | |||
/// The <see cref="Invite"/> code (unique ID). | |||
/// </summary> | |||
/// <remarks> | |||
/// Might be <see langword="null"/> if it is a vanity url invite and | |||
/// it was not set for the <see cref="Guild"/>. | |||
/// </remarks> | |||
[JsonPropertyName("code")] | |||
public string? Code { get; init; } // Required property candidate | |||
public string? Code { get; init; } | |||
/// <summary> | |||
/// The <see cref="Guild"/> this <see cref="Invite"/> is for. | |||
@@ -41,7 +41,7 @@ namespace Discord.Net | |||
#region Channel | |||
/// <inheritdoc/> | |||
public Task<Channel> GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
public Task<Channel?> GetChannelAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(channelId, nameof(channelId)); | |||
return _api.GetChannelAsync(channelId, cancellationToken); | |||
@@ -82,7 +82,7 @@ namespace Discord.Net | |||
} | |||
/// <inheritdoc/> | |||
public Task<Message[]> GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default) | |||
public Task<IEnumerable<Message>> 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 | |||
} | |||
/// <inheritdoc/> | |||
public Task<Message> GetChannelMessageAsync(Snowflake channelId, Snowflake messageId, CancellationToken cancellationToken = default) | |||
public Task<Message?> 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 | |||
} | |||
/// <inheritdoc/> | |||
public Task<User[]> GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default) | |||
public Task<IEnumerable<User>> 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 | |||
} | |||
/// <inheritdoc/> | |||
public Task<InviteWithMetadata[]> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
public Task<IEnumerable<InviteWithMetadata>> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(channelId, nameof(channelId)); | |||
return _api.GetChannelInvitesAsync(channelId, cancellationToken); | |||
@@ -249,7 +249,7 @@ namespace Discord.Net | |||
} | |||
/// <inheritdoc/> | |||
public Task<Message[]> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
public Task<IEnumerable<Message>> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(channelId, nameof(channelId)); | |||
return _api.GetPinnedMessagesAsync(channelId, cancellationToken); | |||
@@ -339,7 +339,7 @@ namespace Discord.Net | |||
} | |||
/// <inheritdoc/> | |||
public Task<ThreadMember[]> ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default) | |||
public Task<IEnumerable<ThreadMember>> 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 | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<Emoji>> ListGuildEmojisAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
Preconditions.NotNull(emoji, nameof(emoji)); | |||
return _api.ListGuildEmojisAsync(guildId, emoji, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Emoji> GetGuildEmojiAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
Preconditions.NotNull(emoji, nameof(emoji)); | |||
return _api.GetGuildEmojiAsync(guildId, emoji, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Emoji> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Emoji> 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); | |||
} | |||
/// <inheritdoc/> | |||
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 | |||
/// <inheritdoc/> | |||
public Task<Guild> CreateGuildAsync(CreateGuildParams args, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotNull(args, nameof(args)); | |||
args.Validate(); | |||
return _api.CreateGuildAsync(args, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Guild> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Guild?> GetGuildPreviewAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildPreviewAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Guild> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task DeleteGuildAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.DeleteGuildAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<GuildChannel>> GetGuildChannelsAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildChannelsAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildChannel> 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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildMember?> GetGuildMemberAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
Preconditions.NotZero(userId, nameof(userId)); | |||
return _api.GetGuildMemberAsync(guildId, userId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<GuildMember>> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<GuildMember>> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildMember?> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildMember> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<string> 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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<Ban>> GetGuildBansAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildBansAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Ban?> GetGuildBanAsync(Snowflake guildId, Snowflake userId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
Preconditions.NotZero(userId, nameof(userId)); | |||
return _api.GetGuildBanAsync(guildId, userId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<Role>> GetGuildRolesAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildRolesAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Role> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<Role>> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Role> 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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Prune> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Prune> 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); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<VoiceRegion>> GetGuildVoiceRegionsAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildVoiceRegionsAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<InviteWithMetadata>> GetGuildInvitesAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildInvitesAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<IEnumerable<Integration>> GetGuildIntegrationsAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildIntegrationsAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task DeleteGuildIntegrationAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.DeleteGuildIntegrationAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildWidget> GetGuildWidgetSettingsAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildWidgetSettingsAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<GuildWidget> ModifyGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.ModifyGuildWidgetAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<object> GetGuildWidgetAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildWidgetAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<Invite?> GetGuildVanityURLAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildVanityURLAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<WelcomeScreen> GetGuildWelcomeScreenAsync(Snowflake guildId, CancellationToken cancellationToken = default) | |||
{ | |||
Preconditions.NotZero(guildId, nameof(guildId)); | |||
return _api.GetGuildWelcomeScreenAsync(guildId, cancellationToken); | |||
} | |||
/// <inheritdoc/> | |||
public Task<WelcomeScreen> 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); | |||
} | |||
/// <inheritdoc/> | |||
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); | |||
} | |||
/// <inheritdoc/> | |||
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 | |||
} | |||
} |
@@ -11,14 +11,14 @@ namespace Discord.Net.Rest | |||
public record ModifyGroupChannelParams | |||
{ | |||
/// <summary> | |||
/// <see cref="Channel"/> name. | |||
/// <see cref="GroupChannel"/> name. | |||
/// </summary> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
/// Base64 encoded icon. | |||
/// <see cref="GroupChannel"/> icon. | |||
/// </summary> | |||
public Optional<string> Icon { get; set; } | |||
public Optional<Image> Icon { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
@@ -0,0 +1,33 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record CreateGuildEmojiParams | |||
{ | |||
/// <summary> | |||
/// Name of the <see cref="Emoji"/>. | |||
/// </summary> | |||
public string? Name { get; set; } // Required property candidate | |||
/// <summary> | |||
/// The 128x128 <see cref="Emoji"/> image. | |||
/// </summary> | |||
public Image Image { get; set; } | |||
/// <summary> | |||
/// <see cref="Role"/>s allowed to use this <see cref="Emoji"/>. | |||
/// </summary> | |||
public Snowflake[]? Roles { get; set; } // Required property candidate | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNullOrWhitespace(Name, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildEmojiParams | |||
{ | |||
/// <summary> | |||
/// Name of the <see cref="Emoji"/>. | |||
/// </summary> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
/// <see cref="Role"/>s allowed to use this <see cref="Emoji"/>. | |||
/// </summary> | |||
public Optional<Snowflake[]?> Roles { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNullOrWhitespace(Name!, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record AddGuildMemberParams | |||
{ | |||
/// <summary> | |||
/// An oauth2 access token granted with the guilds.join to the bot's application for the user you want to add to the guild. | |||
/// </summary> | |||
public string? AccessToken { get; set; } // Required property candidate | |||
/// <summary> | |||
/// Value to set users nickname to. | |||
/// </summary> | |||
public Optional<string> Nick { get; set; } | |||
/// <summary> | |||
/// Array of role ids the member is assigned. | |||
/// </summary> | |||
public Optional<Snowflake[]> Roles { get; set; } | |||
/// <summary> | |||
/// Whether the user is muted in voice channels. | |||
/// </summary> | |||
public Optional<bool> Mute { get; set; } | |||
/// <summary> | |||
/// Whether the user is deafened in voice channels. | |||
/// </summary> | |||
public Optional<bool> Deaf { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNullOrEmpty(AccessToken, nameof(AccessToken)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record BeginGuildPruneParams | |||
{ | |||
/// <summary> | |||
/// Number of days to prune (1-30). | |||
/// </summary> | |||
public Optional<int> Days { get; set; } | |||
/// <summary> | |||
/// Whether 'pruned' is returned, discouraged for large guilds. | |||
/// </summary> | |||
public Optional<bool> ComputePruneCount { get; set; } | |||
/// <summary> | |||
/// Role(s) to include, by id. | |||
/// </summary> | |||
public Optional<Snowflake[]> IncludeRoles { get; set; } | |||
/// <summary> | |||
/// Reason for the prune. | |||
/// </summary> | |||
public Optional<string> Reason { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.AtLeast(Days, Guild.MinAmountOfDaysToPruneFor, nameof(Days)); | |||
Preconditions.AtMost(Days, Guild.MaxAmountOfDaysToPruneFor, nameof(Days)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record CreateGuildBanParams | |||
{ | |||
/// <summary> | |||
/// Number of days to delete messages for (0-7). | |||
/// </summary> | |||
public Optional<int> DeleteMessageDays { get; set; } | |||
/// <summary> | |||
/// Reason for the ban. | |||
/// </summary> | |||
public Optional<string> Reason { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.AtLeast(DeleteMessageDays, Ban.MinDaysToDeleteMessages, nameof(DeleteMessageDays)); | |||
Preconditions.AtMost(DeleteMessageDays, Ban.MaxDaysToDeleteMessages, nameof(DeleteMessageDays)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,83 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record CreateGuildChannelParams | |||
{ | |||
/// <summary> | |||
/// Channel name (1-100 characters). | |||
/// </summary> | |||
public string? Name { get; set; } // Required property candidate | |||
/// <summary> | |||
/// The type of channel. | |||
/// </summary> | |||
public Optional<ChannelType> Type { get; set; } | |||
/// <summary> | |||
/// Channel topic (0-1024 characters). | |||
/// </summary> | |||
public Optional<string> Topic { get; set; } | |||
/// <summary> | |||
/// The bitrate (in bits) of the voice channel (voice only). | |||
/// </summary> | |||
public Optional<int> Bitrate { get; set; } | |||
/// <summary> | |||
/// The user limit of the voice channel (voice only). | |||
/// </summary> | |||
public Optional<int> UserLimit { get; set; } | |||
/// <summary> | |||
/// Amount of seconds a user has to wait before sending another message (0-21600); | |||
/// bots, as well as users with the permission <see cref="Permissions.ManageMessages"/> or | |||
/// <see cref="Permissions.ManageChannels"/>, are unaffected. | |||
/// </summary> | |||
public Optional<int> RateLimitPerUser { get; set; } | |||
/// <summary> | |||
/// Sorting position of the channel. | |||
/// </summary> | |||
public Optional<int> Position { get; set; } | |||
/// <summary> | |||
/// The channel's permission overwrites. | |||
/// </summary> | |||
public Optional<Overwrite[]> PermissionOverwrites { get; set; } | |||
/// <summary> | |||
/// Id of the parent category for a channel. | |||
/// </summary> | |||
public Optional<Snowflake> ParentId { get; set; } | |||
/// <summary> | |||
/// Whether the channel is nsfw. | |||
/// </summary> | |||
public Optional<bool> Nsfw { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
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)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record CreateGuildParams | |||
{ | |||
/// <summary> | |||
/// Name of the guild (2-100 characters). | |||
/// </summary> | |||
public string? Name { get; set; } // Required property candidate | |||
/// <summary> | |||
/// Image for the guild icon. | |||
/// </summary> | |||
public Optional<Image> Icon { get; set; } | |||
/// <summary> | |||
/// Verification level. | |||
/// </summary> | |||
public Optional<VerificationLevel> VerificationLevel { get; set; } | |||
/// <summary> | |||
/// Default message notification level. | |||
/// </summary> | |||
public Optional<DefaultMessageNotificationLevel> DefaultMessageNotifications { get; set; } | |||
/// <summary> | |||
/// Explicit content filter level. | |||
/// </summary> | |||
public Optional<ExplicitContentFilterLevel> ExplicitContentFilter { get; set; } | |||
/// <summary> | |||
/// New guild roles. | |||
/// </summary> | |||
public Optional<Role[]> Roles { get; set; } | |||
/// <summary> | |||
/// New guild's channels. | |||
/// </summary> | |||
public Optional<Channel[]> Channels { get; set; } | |||
/// <summary> | |||
/// Id for afk channel. | |||
/// </summary> | |||
public Optional<Snowflake> AfkChannelId { get; set; } | |||
/// <summary> | |||
/// Afk timeout in seconds. | |||
/// </summary> | |||
public Optional<int> AfkTimeout { get; set; } | |||
/// <summary> | |||
/// The id of the channel where guild notices such as welcome messages and boost events are posted. | |||
/// </summary> | |||
public Optional<Snowflake> SystemChannelId { get; set; } | |||
/// <summary> | |||
/// System channel flags. | |||
/// </summary> | |||
public Optional<SystemChannelFlags> SystemChannelFlags { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNull(Name, nameof(Name)); | |||
Preconditions.LengthAtLeast(Name, Guild.MinGuildNameLength, nameof(Name)); | |||
Preconditions.LengthAtMost(Name, Guild.MaxGuildNameLength, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record CreateGuildRoleParams | |||
{ | |||
/// <summary> | |||
/// Name of the role. | |||
/// </summary> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
/// Bitwise value of the enabled/disabled permissions. | |||
/// </summary> | |||
public Optional<Permissions> Permissions { get; set; } | |||
/// <summary> | |||
/// Role color. | |||
/// </summary> | |||
public Optional<Color> Color { get; set; } | |||
/// <summary> | |||
/// Whether the role should be displayed separately in the sidebar. | |||
/// </summary> | |||
public Optional<bool> Hoist { get; set; } | |||
/// <summary> | |||
/// Whether the role should be mentionable. | |||
/// </summary> | |||
public Optional<bool> Mentionable { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNullOrEmpty(Name!, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record GetGuildParams | |||
{ | |||
/// <summary> | |||
/// When true, will return approximate member and presence counts for the guild. | |||
/// </summary> | |||
public Optional<bool> WithCounts { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
using System.Collections.Generic; | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record GetGuildPruneCountParams | |||
{ | |||
/// <summary> | |||
/// Number of days to count prune for (1-30). | |||
/// </summary> | |||
public Optional<int> Days { get; set; } | |||
/// <summary> | |||
/// Role(s) to include, by id. | |||
/// </summary> | |||
public Optional<IEnumerable<Snowflake>> IncludeRoles { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.AtLeast(Days, Guild.MinAmountOfDaysToPruneFor, nameof(Days)); | |||
Preconditions.AtMost(Days, Guild.MaxAmountOfDaysToPruneFor, nameof(Days)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ListGuildMembersParams | |||
{ | |||
/// <summary> | |||
/// Max number of members to return (1-1000). | |||
/// </summary> | |||
public int Limit { get; set; } | |||
/// <summary> | |||
/// The highest user id in the previous page. | |||
/// </summary> | |||
public Snowflake After { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.AtLeast(Limit, Guild.MinUserLimitToList, nameof(Limit)); | |||
Preconditions.AtMost(Limit, Guild.MaxUserLimitToList, nameof(Limit)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyCurrentUserNickParams | |||
{ | |||
/// <summary> | |||
/// Value to set users nickname to. | |||
/// </summary> | |||
public Optional<string?> Nick { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.LengthAtMost(Nick, GuildMember.MaxNicknameLength, nameof(Nick)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
using System; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyCurrentUserVoiceStateParams | |||
{ | |||
/// <summary> | |||
/// The id of the channel the user is currently in. | |||
/// </summary> | |||
public Snowflake ChannelId { get; set; } | |||
/// <summary> | |||
/// Toggles the user's suppress state. | |||
/// </summary> | |||
public Optional<bool> Suppress { get; set; } | |||
/// <summary> | |||
/// Sets the user's request to speak. | |||
/// </summary> | |||
public Optional<DateTimeOffset?> RequestToSpeakTimestamp { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildChannelPositionsParams | |||
{ | |||
/// <summary> | |||
/// Channel id. | |||
/// </summary> | |||
public Snowflake Id { get; set; } | |||
/// <summary> | |||
/// Sorting position of the channel. | |||
/// </summary> | |||
public int? Position { get; set; } | |||
/// <summary> | |||
/// Syncs the permission overwrites with the new parent, if moving to a new category. | |||
/// </summary> | |||
public bool? LockPermissions { get; set; } | |||
/// <summary> | |||
/// The new parent ID for the channel that is moved. | |||
/// </summary> | |||
public Snowflake? ParentId { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildMemberParams | |||
{ | |||
/// <summary> | |||
/// Value to set users nickname to. | |||
/// </summary> | |||
public Optional<string?> Nick { get; set; } | |||
/// <summary> | |||
/// Array of role ids the member is assigned. | |||
/// </summary> | |||
public Optional<Snowflake[]?> Roles { get; set; } | |||
/// <summary> | |||
/// Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel. | |||
/// </summary> | |||
public Optional<bool?> Mute { get; set; } | |||
/// <summary> | |||
/// Whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel. | |||
/// </summary> | |||
public Optional<bool?> Deaf { get; set; } | |||
/// <summary> | |||
/// Id of channel to move user to (if they are connected to voice). | |||
/// </summary> | |||
public Optional<Snowflake?> ChannelId { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.LengthAtMost(Nick, GuildMember.MaxNicknameLength, nameof(Nick)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,115 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildParams | |||
{ | |||
/// <summary> | |||
/// Guild name. | |||
/// </summary> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
/// Guild voice region id (deprecated). | |||
/// </summary> | |||
public Optional<string?> Region { get; set; } | |||
/// <summary> | |||
/// Verification level. | |||
/// </summary> | |||
public Optional<int?> VerificationLevel { get; set; } | |||
/// <summary> | |||
/// Default message notification level. | |||
/// </summary> | |||
public Optional<int?> DefaultMessageNotifications { get; set; } | |||
/// <summary> | |||
/// Explicit content filter level. | |||
/// </summary> | |||
public Optional<int?> ExplicitContentFilter { get; set; } | |||
/// <summary> | |||
/// Id for afk channel. | |||
/// </summary> | |||
public Optional<Snowflake?> AfkChannelId { get; set; } | |||
/// <summary> | |||
/// Afk timeout in seconds. | |||
/// </summary> | |||
public Optional<int> AfkTimeout { get; set; } | |||
/// <summary> | |||
/// Image for the guild icon (can be animated gif when the server has the ANIMATED_ICON feature). | |||
/// </summary> | |||
public Optional<Image?> Icon { get; set; } | |||
/// <summary> | |||
/// User id to transfer guild ownership to (must be owner). | |||
/// </summary> | |||
public Optional<Snowflake> OwnerId { get; set; } | |||
/// <summary> | |||
/// Image for the guild splash (when the server has the INVITE_SPLASH feature). | |||
/// </summary> | |||
public Optional<Image?> Splash { get; set; } | |||
/// <summary> | |||
/// Image for the guild discovery splash (when the server has the DISCOVERABLE feature). | |||
/// </summary> | |||
public Optional<Image?> DiscoverySplash { get; set; } | |||
/// <summary> | |||
/// Image for the guild banner (when the server has the BANNER feature). | |||
/// </summary> | |||
public Optional<Image?> Banner { get; set; } | |||
/// <summary> | |||
/// The id of the channel where guild notices such as welcome messages and boost events are posted. | |||
/// </summary> | |||
public Optional<Snowflake?> SystemChannelId { get; set; } | |||
/// <summary> | |||
/// System channel flags. | |||
/// </summary> | |||
public Optional<int> SystemChannelFlags { get; set; } | |||
/// <summary> | |||
/// The id of the channel where Community guilds display rules and/or guidelines. | |||
/// </summary> | |||
public Optional<Snowflake?> RulesChannelId { get; set; } | |||
/// <summary> | |||
/// The id of the channel where admins and moderators of Community guilds receive notices from Discord. | |||
/// </summary> | |||
public Optional<Snowflake?> PublicUpdatesChannelId { get; set; } | |||
/// <summary> | |||
/// The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US". | |||
/// </summary> | |||
public Optional<string?> PreferredLocale { get; set; } | |||
/// <summary> | |||
/// Enabled guild features. | |||
/// </summary> | |||
public Optional<string[]> Features { get; set; } | |||
/// <summary> | |||
/// The description for the guild, if the guild is discoverable. | |||
/// </summary> | |||
public Optional<string?> Description { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNull(Name!, nameof(Name)); | |||
Preconditions.LengthAtLeast(Name!, Guild.MinGuildNameLength, nameof(Name)); | |||
Preconditions.LengthAtMost(Name!, Guild.MaxGuildNameLength, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildRoleParams | |||
{ | |||
/// <summary> | |||
/// Name of the role. | |||
/// </summary> | |||
public Optional<string?> Name { get; set; } | |||
/// <summary> | |||
/// Bitwise value of the enabled/disabled permissions. | |||
/// </summary> | |||
public Optional<string?> Permissions { get; set; } | |||
/// <summary> | |||
/// RGB color value. | |||
/// </summary> | |||
public Optional<Color?> Color { get; set; } | |||
/// <summary> | |||
/// Whether the role should be displayed separately in the sidebar. | |||
/// </summary> | |||
public Optional<bool?> Hoist { get; set; } | |||
/// <summary> | |||
/// Whether the role should be mentionable. | |||
/// </summary> | |||
public Optional<bool?> Mentionable { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNullOrEmpty(Name!, nameof(Name)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildRolePositionsParams | |||
{ | |||
/// <summary> | |||
/// Role. | |||
/// </summary> | |||
public Snowflake Id { get; set; } | |||
/// <summary> | |||
/// Sorting position of the role. | |||
/// </summary> | |||
public Optional<int?> Position { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyGuildWelcomeScreenParams | |||
{ | |||
/// <summary> | |||
/// Whether the welcome screen is enabled. | |||
/// </summary> | |||
public Optional<bool?> Enabled { get; set; } | |||
/// <summary> | |||
/// Channels linked in the welcome screen and their display options. | |||
/// </summary> | |||
public Optional<WelcomeScreenChannel[]?> WelcomeChannels { get; set; } | |||
/// <summary> | |||
/// The server description to show in the welcome screen. | |||
/// </summary> | |||
public Optional<string?> Description { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record ModifyUserVoiceStateParams | |||
{ | |||
/// <summary> | |||
/// The id of the channel the user is currently in. | |||
/// </summary> | |||
public Snowflake ChannelId { get; set; } | |||
/// <summary> | |||
/// Toggles the user's suppress state. | |||
/// </summary> | |||
public Optional<bool> Suppress { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
using Discord.Net.Models; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Parameters to add to the request. | |||
/// </summary> | |||
public record SearchGuildMembersParams | |||
{ | |||
/// <summary> | |||
/// Query string to match username(s) and nickname(s) against. | |||
/// </summary> | |||
public string? Query { get; set; } // Required property candidate | |||
/// <summary> | |||
/// Max number of members to return (1-1000). | |||
/// </summary> | |||
public Optional<int> Limit { get; set; } | |||
/// <summary> | |||
/// Validates the data. | |||
/// </summary> | |||
public void Validate() | |||
{ | |||
Preconditions.NotNull(Query, nameof(Query)); | |||
Preconditions.AtLeast(Limit, Guild.MinUserLimitToList, nameof(Limit)); | |||
Preconditions.AtMost(Limit, Guild.MaxUserLimitToList, nameof(Limit)); | |||
} | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
using System.IO; | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Container to send a base64 encoded image to Discord. | |||
/// </summary> | |||
/// <remarks> | |||
/// <see href="https://discord.com/developers/docs/reference#image-data"/> | |||
/// </remarks> | |||
public struct Image | |||
{ | |||
/// <summary> | |||
/// The image stream. | |||
/// </summary> | |||
public Stream? Stream { get; } | |||
/// <summary> | |||
/// The format of the image. | |||
/// </summary> | |||
public ImageFormat StreamFormat { get; } | |||
/// <summary> | |||
/// The image hash. | |||
/// </summary> | |||
public string? Hash { get; } | |||
/// <summary> | |||
/// Creates an <see cref="Image"/> based on a <see cref="System.IO.Stream"/>. | |||
/// </summary> | |||
/// <param name="stream"> | |||
/// Image stream. | |||
/// </param> | |||
/// <param name="format"> | |||
/// Image format. | |||
/// </param> | |||
public Image(Stream stream, ImageFormat format) | |||
{ | |||
Stream = stream; | |||
StreamFormat = format; | |||
Hash = null; | |||
} | |||
/// <summary> | |||
/// Creates an <see cref="Image"/> based on the image hash. | |||
/// </summary> | |||
/// <param name="hash"> | |||
/// Image hash. | |||
/// </param> | |||
public Image(string hash) | |||
{ | |||
Stream = null; | |||
StreamFormat = ImageFormat.Jpeg; | |||
Hash = hash; | |||
} | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Declares an enum which represents the format of the image. | |||
/// </summary> | |||
public enum ImageFormat | |||
{ | |||
/// <summary> | |||
/// The image format is WebP. | |||
/// </summary> | |||
WebP, | |||
/// <summary> | |||
/// The image format is Png. | |||
/// </summary> | |||
Png, | |||
/// <summary> | |||
/// The image format is Jpg/Jpeg. | |||
/// </summary> | |||
Jpeg, | |||
/// <summary> | |||
/// The image format is Gif. | |||
/// </summary> | |||
Gif, | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
namespace Discord.Net.Rest | |||
{ | |||
/// <summary> | |||
/// Response to count or begin a prune. | |||
/// </summary> | |||
/// <remarks> | |||
/// <see href="https://discord.com/developers/docs/resources/guild#get-guild-prune-count"/> or | |||
/// <see href="https://discord.com/developers/docs/resources/guild#begin-guild-prune"/> | |||
/// </remarks> | |||
public record Prune | |||
{ | |||
/// <summary> | |||
/// Gets the number of members that would or were affected in a prune operation. | |||
/// </summary> | |||
public Optional<int> Pruned { get; init; } | |||
} | |||
} |