Browse Source

Add missing rest endpoints

Add guild template, invite, stage instance, user, voice, and webhhok rest endpoints
5.0
Paulo 3 years ago
parent
commit
0b6838fd01
21 changed files with 1515 additions and 11 deletions
  1. +2
    -2
      src/Models/Channels/Channel.cs
  2. +10
    -0
      src/Models/Channels/StageInstance.cs
  3. +10
    -0
      src/Models/Guilds/Guild.cs
  4. +20
    -0
      src/Models/Guilds/GuildTemplate.cs
  5. +10
    -0
      src/Models/Webhooks/Webhook.cs
  6. +295
    -0
      src/Rest/DiscordRestClient.cs
  7. +671
    -9
      src/Rest/Net/IDiscordRestApi.cs
  8. +21
    -0
      src/Rest/Net/Requests/Channels/CreateDMParams.cs
  9. +36
    -0
      src/Rest/Net/Requests/Channels/CreateStageInstanceParams.cs
  10. +30
    -0
      src/Rest/Net/Requests/Channels/ModifyStageInstanceParams.cs
  11. +32
    -0
      src/Rest/Net/Requests/Guilds/CreateGuildTemplateParams.cs
  12. +30
    -0
      src/Rest/Net/Requests/Guilds/CreateGuildfromGuildTemplateParams.cs
  13. +32
    -0
      src/Rest/Net/Requests/Guilds/ModifyGuildTemplateParams.cs
  14. +25
    -0
      src/Rest/Net/Requests/Invites/GetInviteParams.cs
  15. +35
    -0
      src/Rest/Net/Requests/Users/GetCurrentUserGuildsParams.cs
  16. +28
    -0
      src/Rest/Net/Requests/Users/ModifyCurrentUserParams.cs
  17. +30
    -0
      src/Rest/Net/Requests/Webhooks/CreateWebhookParams.cs
  18. +54
    -0
      src/Rest/Net/Requests/Webhooks/EditWebhookMessageParams.cs
  19. +78
    -0
      src/Rest/Net/Requests/Webhooks/ExecuteWebhookParams.cs
  20. +36
    -0
      src/Rest/Net/Requests/Webhooks/ModifyWebhookParams.cs
  21. +30
    -0
      src/Rest/Net/Requests/Webhooks/ModifyWebhookWithTokenParams.cs

+ 2
- 2
src/Models/Channels/Channel.cs View File

@@ -32,12 +32,12 @@ namespace Discord.Net.Models
public const int MaxChannelTopicLength = 1024; public const int MaxChannelTopicLength = 1024;


/// <summary> /// <summary>
/// Minimum langth of a channel topic.
/// Minimum duration to rate limit per user.
/// </summary> /// </summary>
public const int MinRateLimitPerUserDuration = 0; public const int MinRateLimitPerUserDuration = 0;


/// <summary> /// <summary>
/// Maximum langth of a channel topic.
/// Maximum duration to rate limit per user.
/// </summary> /// </summary>
public const int MaxRateLimitPerUserDuration = 21600; public const int MaxRateLimitPerUserDuration = 21600;




+ 10
- 0
src/Models/Channels/StageInstance.cs View File

@@ -11,6 +11,16 @@ namespace Discord.Net.Models
public record StageInstance public record StageInstance
{ {
/// <summary> /// <summary>
/// Minimum langth of a stage channel topic.
/// </summary>
public const int MinStageChannelTopicLength = 1;

/// <summary>
/// Maximum langth of a stage channel topic.
/// </summary>
public const int MaxStageChannelTopicLength = 120;

/// <summary>
/// The id of this <see cref="StageInstance"/>. /// The id of this <see cref="StageInstance"/>.
/// </summary> /// </summary>
[JsonPropertyName("id")] [JsonPropertyName("id")]


+ 10
- 0
src/Models/Guilds/Guild.cs View File

@@ -42,6 +42,16 @@ namespace Discord.Net.Models
public const int MaxUserLimitToList = 1000; public const int MaxUserLimitToList = 1000;


/// <summary> /// <summary>
/// Minimum limit of guilds to list.
/// </summary>
public const int MinGetGuildsAmount = 1;

/// <summary>
/// Maximum limit of guilds to list.
/// </summary>
public const int MaxGetGuildsAmount = 200;

/// <summary>
/// <see cref="Guild"/> id. /// <see cref="Guild"/> id.
/// </summary> /// </summary>
[JsonPropertyName("id")] [JsonPropertyName("id")]


+ 20
- 0
src/Models/Guilds/GuildTemplate.cs View File

@@ -12,6 +12,26 @@ namespace Discord.Net.Models
public record GuildTemplate public record GuildTemplate
{ {
/// <summary> /// <summary>
/// Minimum langth of a template name.
/// </summary>
public const int MinTemplateNameLength = 1;

/// <summary>
/// Maximum langth of a template name.
/// </summary>
public const int MaxTemplateNameLength = 100;

/// <summary>
/// Minimum langth of a template description.
/// </summary>
public const int MinTemplateDescriptionLength = 0;

/// <summary>
/// Maximum langth of a template description.
/// </summary>
public const int MaxTemplateDescriptionLength = 120;

/// <summary>
/// The template code (unique ID). /// The template code (unique ID).
/// </summary> /// </summary>
[JsonPropertyName("code")] [JsonPropertyName("code")]


+ 10
- 0
src/Models/Webhooks/Webhook.cs View File

@@ -11,6 +11,16 @@ namespace Discord.Net.Models
public record Webhook public record Webhook
{ {
/// <summary> /// <summary>
/// Maximum langth of a webhook name.
/// </summary>
public const int MinNameLength = 1;

/// <summary>
/// Maximum langth of a webhook name.
/// </summary>
public const int MaxNameLength = 80;

/// <summary>
/// The id of the <see cref="Webhook"/>. /// The id of the <see cref="Webhook"/>.
/// </summary> /// </summary>
[JsonPropertyName("id")] [JsonPropertyName("id")]


+ 295
- 0
src/Rest/DiscordRestClient.cs View File

@@ -771,5 +771,300 @@ namespace Discord.Net
} }


#endregion Guild #endregion Guild

#region Guild Template

/// <inheritdoc/>
public Task<GuildTemplate> GetGuildTemplateAsync(string templateCode, CancellationToken cancellationToken = default)
{
Preconditions.NotNullOrEmpty(templateCode, nameof(templateCode));
return _api.GetGuildTemplateAsync(templateCode, cancellationToken);
}

/// <inheritdoc/>
public Task<Guild> CreateGuildfromGuildTemplateAsync(string templateCode, CreateGuildfromGuildTemplateParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNullOrEmpty(templateCode, nameof(templateCode));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.CreateGuildfromGuildTemplateAsync(templateCode, args, cancellationToken);
}

/// <inheritdoc/>
public Task<IEnumerable<GuildTemplate>> GetGuildTemplatesAsync(Snowflake guildId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
return _api.GetGuildTemplatesAsync(guildId, cancellationToken);
}

/// <inheritdoc/>
public Task<GuildTemplate> CreateGuildTemplateAsync(Snowflake guildId, CreateGuildTemplateParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.CreateGuildTemplateAsync(guildId, args, cancellationToken);
}

/// <inheritdoc/>
public Task<GuildTemplate> SyncGuildTemplateAsync(Snowflake guildId, string templateCode, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
Preconditions.NotNullOrEmpty(templateCode, nameof(templateCode));
return _api.SyncGuildTemplateAsync(guildId, templateCode, cancellationToken);
}

/// <inheritdoc/>
public Task<GuildTemplate> ModifyGuildTemplateAsync(Snowflake guildId, string templateCode, ModifyGuildTemplateParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
Preconditions.NotNullOrEmpty(templateCode, nameof(templateCode));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ModifyGuildTemplateAsync(guildId, templateCode, args, cancellationToken);
}

/// <inheritdoc/>
public Task<GuildTemplate> DeleteGuildTemplateAsync(Snowflake guildId, string templateCode, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
Preconditions.NotNullOrEmpty(templateCode, nameof(templateCode));
return _api.DeleteGuildTemplateAsync(guildId, templateCode, cancellationToken);
}

#endregion Guild Template

#region Invite

/// <inheritdoc/>
public Task<Invite> GetInviteAsync(string inviteCode, GetInviteParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNullOrEmpty(inviteCode, nameof(inviteCode));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.GetInviteAsync(inviteCode, args, cancellationToken);
}

/// <inheritdoc/>
public Task<Invite> DeleteInviteAsync(string inviteCode, CancellationToken cancellationToken = default)
{
Preconditions.NotNullOrEmpty(inviteCode, nameof(inviteCode));
return _api.DeleteInviteAsync(inviteCode, cancellationToken);
}

#endregion Invite

#region Stage Instance

/// <inheritdoc/>
public Task<StageInstance> CreateStageInstanceAsync(CreateStageInstanceParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.CreateStageInstanceAsync(args, cancellationToken);
}

/// <inheritdoc/>
public Task<StageInstance> GetStageInstanceAsync(Snowflake channelId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(channelId, nameof(channelId));
return _api.GetStageInstanceAsync(channelId, cancellationToken);
}

/// <inheritdoc/>
public Task<StageInstance> ModifyStageInstanceAsync(Snowflake channelId, ModifyStageInstanceParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(channelId, nameof(channelId));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ModifyStageInstanceAsync(channelId, args, cancellationToken);
}

/// <inheritdoc/>
public Task DeleteStageInstanceAsync(Snowflake channelId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(channelId, nameof(channelId));
return _api.DeleteStageInstanceAsync(channelId, cancellationToken);
}

#endregion Stage Instance

#region User

/// <inheritdoc/>
public Task<User> GetCurrentUserAsync(CancellationToken cancellationToken = default)
{
return _api.GetCurrentUserAsync(cancellationToken);
}

/// <inheritdoc/>
public Task<User> GetUserAsync(Snowflake userId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(userId, nameof(userId));
return _api.GetUserAsync(userId, cancellationToken);
}

/// <inheritdoc/>
public Task<User> ModifyCurrentUserAsync(ModifyCurrentUserParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ModifyCurrentUserAsync(args, cancellationToken);
}

/// <inheritdoc/>
public Task<IEnumerable<Guild>> GetCurrentUserGuildsAsync(GetCurrentUserGuildsParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.GetCurrentUserGuildsAsync(args, cancellationToken);
}

/// <inheritdoc/>
public Task LeaveGuildAsync(Snowflake guildId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
return _api.LeaveGuildAsync(guildId, cancellationToken);
}

/// <inheritdoc/>
public Task<DMChannel> CreateDMAsync(CreateDMParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.CreateDMAsync(args, cancellationToken);
}

/// <inheritdoc/>
public Task<IEnumerable<Connection>> GetUserConnectionsAsync(CancellationToken cancellationToken = default)
{
return _api.GetUserConnectionsAsync(cancellationToken);
}

#endregion User

#region Voice

/// <inheritdoc/>
public Task<IEnumerable<VoiceRegion>> ListVoiceRegionsAsync(CancellationToken cancellationToken = default)
{
return _api.ListVoiceRegionsAsync(cancellationToken);
}

#endregion Voice

#region Webhook

/// <inheritdoc/>
public Task<Webhook> CreateWebhookAsync(Snowflake channelId, CreateWebhookParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(channelId, nameof(channelId));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.CreateWebhookAsync(channelId, args, cancellationToken);
}

/// <inheritdoc/>
public Task<IEnumerable<Webhook>> GetChannelWebhooksAsync(Snowflake channelId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(channelId, nameof(channelId));
return _api.GetChannelWebhooksAsync(channelId, cancellationToken);
}

/// <inheritdoc/>
public Task<IEnumerable<Webhook>> GetGuildWebhooksAsync(Snowflake guildId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(guildId, nameof(guildId));
return _api.GetGuildWebhooksAsync(guildId, cancellationToken);
}

/// <inheritdoc/>
public Task<Webhook> GetWebhookAsync(Snowflake webhookId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
return _api.GetWebhookAsync(webhookId, cancellationToken);
}

/// <inheritdoc/>
public Task<Webhook> GetWebhookAsync(Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
return _api.GetWebhookAsync(webhookId, webhookToken, cancellationToken);
}

/// <inheritdoc/>
public Task<Webhook> ModifyWebhookAsync(Snowflake webhookId, ModifyWebhookParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ModifyWebhookAsync(webhookId, args, cancellationToken);
}

/// <inheritdoc/>
public Task<Webhook> ModifyWebhookAsync(Snowflake webhookId, string webhookToken, ModifyWebhookWithTokenParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ModifyWebhookAsync(webhookId, webhookToken, args, cancellationToken);
}

/// <inheritdoc/>
public Task DeleteWebhookAsync(Snowflake webhookId, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
return _api.DeleteWebhookAsync(webhookId, cancellationToken);
}

/// <inheritdoc/>
public Task DeleteWebhookAsync(Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
return _api.DeleteWebhookAsync(webhookId, webhookToken, cancellationToken);
}

/// <inheritdoc/>
public Task<Message> ExecuteWebhookAsync(Snowflake webhookId, string webhookToken, ExecuteWebhookParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.ExecuteWebhookAsync(webhookId, webhookToken, args, cancellationToken);
}

/// <inheritdoc/>
public Task<Message> GetWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(messageId, nameof(messageId));
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
return _api.GetWebhookMessageAsync(messageId, webhookId, webhookToken, cancellationToken);
}

/// <inheritdoc/>
public Task<Message> EditWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, EditWebhookMessageParams args, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(messageId, nameof(messageId));
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
Preconditions.NotNull(args, nameof(args));
args.Validate();
return _api.EditWebhookMessageAsync(messageId, webhookId, webhookToken, args, cancellationToken);
}

/// <inheritdoc/>
public Task DeleteWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default)
{
Preconditions.NotZero(messageId, nameof(messageId));
Preconditions.NotZero(webhookId, nameof(webhookId));
Preconditions.NotNull(webhookToken, nameof(webhookToken));
return _api.DeleteWebhookMessageAsync(messageId, webhookId, webhookToken, cancellationToken);
}

#endregion Webhook
} }
} }

+ 671
- 9
src/Rest/Net/IDiscordRestApi.cs View File

@@ -153,7 +153,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of <see cref="Message"/>s from the <see cref="Channel"/>.
/// A task that contains a collection of <see cref="Message"/>s from the <see cref="Channel"/>.
/// </returns> /// </returns>
Task<IEnumerable<Message>> GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default); Task<IEnumerable<Message>> GetChannelMessagesAsync(Snowflake channelId, GetChannelMessagesParams args, CancellationToken cancellationToken = default);


@@ -193,7 +193,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains the <see cref="Message"/> created.
/// A task that contains the created <see cref="Message"/>.
/// </returns> /// </returns>
Task<Message> CreateMessageAsync(Snowflake channelId, CreateMessageParams args, CancellationToken cancellationToken = default); Task<Message> CreateMessageAsync(Snowflake channelId, CreateMessageParams args, CancellationToken cancellationToken = default);


@@ -311,7 +311,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of <see cref="User"/>s that reacted with
/// A task that contains a collection of <see cref="User"/>s that reacted with
/// the provided <see cref="Emoji"/>. /// the provided <see cref="Emoji"/>.
/// </returns> /// </returns>
Task<IEnumerable<User>> GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default); Task<IEnumerable<User>> GetReactionsAsync(Snowflake channelId, Snowflake messageId, Emoji emoji, GetReactionsParams args, CancellationToken cancellationToken = default);
@@ -462,7 +462,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of <see cref="InviteWithMetadata"/>s.
/// A task that contains a collection of <see cref="InviteWithMetadata"/>s.
/// </returns> /// </returns>
Task<IEnumerable<InviteWithMetadata>> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default); Task<IEnumerable<InviteWithMetadata>> GetChannelInvitesAsync(Snowflake channelId, CancellationToken cancellationToken = default);


@@ -553,7 +553,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of all pinned <see cref="Message"/>s.
/// A task that contains a collection of all pinned <see cref="Message"/>s.
/// </returns> /// </returns>
Task<IEnumerable<Message>> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default); Task<IEnumerable<Message>> GetPinnedMessagesAsync(Snowflake channelId, CancellationToken cancellationToken = default);


@@ -776,7 +776,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of <see cref="ThreadMember"/>s that are part of the
/// A task that contains a collection of <see cref="ThreadMember"/>s that are part of the
/// specified <see cref="ThreadChannel"/>. /// specified <see cref="ThreadChannel"/>.
/// </returns> /// </returns>
Task<IEnumerable<ThreadMember>> ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default); Task<IEnumerable<ThreadMember>> ListThreadMembersAsync(Snowflake channelId, CancellationToken cancellationToken = default);
@@ -879,7 +879,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains an array of <see cref="Emoji"/>s.
/// A task that contains a collection of <see cref="Emoji"/>s.
/// </returns> /// </returns>
Task<IEnumerable<Emoji>> ListGuildEmojisAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default); Task<IEnumerable<Emoji>> ListGuildEmojisAsync(Snowflake guildId, Emoji emoji, CancellationToken cancellationToken = default);


@@ -1158,7 +1158,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains the returned collection of <see cref="GuildMember"/>s.
/// A task that contains a collection of <see cref="GuildMember"/>s.
/// </returns> /// </returns>
Task<IEnumerable<GuildMember>> ListGuildMembersAsync(Snowflake guildId, ListGuildMembersParams args, CancellationToken cancellationToken = default); Task<IEnumerable<GuildMember>> ListGuildMembersAsync(Snowflake guildId, ListGuildMembersParams args, CancellationToken cancellationToken = default);


@@ -1178,7 +1178,7 @@ namespace Discord.Net.Rest
/// Cancellation token for the request. /// Cancellation token for the request.
/// </param> /// </param>
/// <returns> /// <returns>
/// A task that contains the returned collection of <see cref="GuildMember"/>s.
/// A task that contains a collection of <see cref="GuildMember"/>s.
/// </returns> /// </returns>
Task<IEnumerable<GuildMember>> SearchGuildMembersAsync(Snowflake guildId, SearchGuildMembersParams args, CancellationToken cancellationToken = default); Task<IEnumerable<GuildMember>> SearchGuildMembersAsync(Snowflake guildId, SearchGuildMembersParams args, CancellationToken cancellationToken = default);


@@ -1758,5 +1758,667 @@ namespace Discord.Net.Rest
Task ModifyUserVoiceStateAsync(Snowflake guildId, Snowflake userId, ModifyUserVoiceStateParams args, CancellationToken cancellationToken = default); Task ModifyUserVoiceStateAsync(Snowflake guildId, Snowflake userId, ModifyUserVoiceStateParams args, CancellationToken cancellationToken = default);


#endregion Guild #endregion Guild

#region Guild Template

/// <summary>
/// Gets a <see cref="GuildTemplate"/> for the given code.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#get-guild-template"/>
/// </remarks>
/// <param name="templateCode">
/// The <see cref="GuildTemplate"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the requested <see cref="GuildTemplate"/>; or <see langword="null"/> if it's not found.
/// </returns>
Task<GuildTemplate> GetGuildTemplateAsync(string templateCode, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a new <see cref="Guild"/> based on a template.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-template"/>
/// </remarks>
/// <param name="templateCode">
/// The <see cref="GuildTemplate"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the created <see cref="Guild"/>.
/// </returns>
Task<Guild> CreateGuildfromGuildTemplateAsync(string templateCode, CreateGuildfromGuildTemplateParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets all <see cref="GuildTemplate"/>s within a <see cref="Guild"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#get-guild-templates"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains a collection of <see cref="GuildTemplate"/>s.
/// </returns>
Task<IEnumerable<GuildTemplate>> GetGuildTemplatesAsync(Snowflake guildId, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a <see cref="GuildTemplate"/> for the <see cref="Guild"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#create-guild-template"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the created <see cref="GuildTemplate"/>.
/// </returns>
Task<GuildTemplate> CreateGuildTemplateAsync(Snowflake guildId, CreateGuildTemplateParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Syncs the <see cref="GuildTemplate"/> to the guild's current state.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#sync-guild-template"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="templateCode">
/// The <see cref="GuildTemplate"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the updated <see cref="GuildTemplate"/>.
/// </returns>
Task<GuildTemplate> SyncGuildTemplateAsync(Snowflake guildId, string templateCode, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies the <see cref="GuildTemplate"/>'s metadata.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#modify-guild-template"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="templateCode">
/// The <see cref="GuildTemplate"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the updated <see cref="GuildTemplate"/>.
/// </returns>
Task<GuildTemplate> ModifyGuildTemplateAsync(Snowflake guildId, string templateCode, ModifyGuildTemplateParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes the <see cref="GuildTemplate"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/guild-template#delete-guild-template"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="templateCode">
/// The <see cref="GuildTemplate"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the deleted <see cref="GuildTemplate"/>.
/// </returns>
Task<GuildTemplate> DeleteGuildTemplateAsync(Snowflake guildId, string templateCode, CancellationToken cancellationToken = default);

#endregion Guild Template

#region Invite

/// <summary>
/// Gets an <see cref="Invite"/> for the given code.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/invite#get-invite"/>
/// </remarks>
/// <param name="inviteCode">
/// The <see cref="Invite"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains an <see cref="Invite"/>; or <see langword="null"/> if it is not found.
/// </returns>
Task<Invite> GetInviteAsync(string inviteCode, GetInviteParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes an <see cref="Invite"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/invite#delete-invite"/>
/// </remarks>
/// <param name="inviteCode">
/// The <see cref="Invite"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the deleted <see cref="Invite"/>.
/// </returns>
Task<Invite> DeleteInviteAsync(string inviteCode, CancellationToken cancellationToken = default);

#endregion Invite

#region Stage Instance

/// <summary>
/// Creates a new <see cref="StageInstance"/> associated to a <see cref="StageChannel"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/stage-instance#create-stage-instance"/>
/// </remarks>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the created <see cref="StageInstance"/>.
/// </returns>
Task<StageInstance> CreateStageInstanceAsync(CreateStageInstanceParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the <see cref="StageInstance"/> associated with the <see cref="StageChannel"/>, if it exists.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/stage-instance#get-stage-instance"/>
/// </remarks>
/// <param name="channelId">
/// The <see cref="Channel"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the created <see cref="StageInstance"/>; or <see langword="null"/> if it does not exist.
/// </returns>
Task<StageInstance> GetStageInstanceAsync(Snowflake channelId, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies an existing <see cref="StageInstance"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance"/>
/// </remarks>
/// <param name="channelId">
/// The <see cref="Channel"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the updated <see cref="StageInstance"/>.
/// </returns>
Task<StageInstance> ModifyStageInstanceAsync(Snowflake channelId, ModifyStageInstanceParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes an <see cref="StageInstance"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance"/>
/// </remarks>
/// <param name="channelId">
/// The <see cref="Channel"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that represents this asynchronous operation.
/// </returns>
Task DeleteStageInstanceAsync(Snowflake channelId, CancellationToken cancellationToken = default);

#endregion Stage Instance

#region User

/// <summary>
/// Gets the current <see cref="User"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#get-current-user"/>
/// </remarks>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing the current <see cref="User"/>.
/// </returns>
Task<User> GetCurrentUserAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Gets a <see cref="User"/> for a given identifier.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#get-user"/>
/// </remarks>
/// <param name="userId">
/// The <see cref="User"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a <see cref="User"/>; or <see langword="null"/> if not found.
/// </returns>
Task<User> GetUserAsync(Snowflake userId, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies the current <see cref="User"/>'s account settings.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#modify-current-user"/>
/// </remarks>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing the updated current <see cref="User"/>.
/// </returns>
Task<User> ModifyCurrentUserAsync(ModifyCurrentUserParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets a collection of partial <see cref="Guild"/>s the current user is a member of.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#get-current-user-guilds"/>
/// </remarks>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a collection of <see cref="Guild"/>s.
/// </returns>
Task<IEnumerable<Guild>> GetCurrentUserGuildsAsync(GetCurrentUserGuildsParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Leaves a guild for the current <see cref="User"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#leave-guild"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that represents this asynchronous operation.
/// </returns>
Task LeaveGuildAsync(Snowflake guildId, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a new <see cref="DMChannel"/> with a <see cref="User"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#create-dm"/>
/// </remarks>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a <see cref="DMChannel"/>.
/// </returns>
Task<DMChannel> CreateDMAsync(CreateDMParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the current <see cref="User"/>'s <see cref="Connection"/>s.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/user#get-user-connections"/>
/// </remarks>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a collection of <see cref="Connection"/>s.
/// </returns>
Task<IEnumerable<Connection>> GetUserConnectionsAsync(CancellationToken cancellationToken = default);

#endregion User

#region Voice

/// <summary>
/// Gets a collection of <see cref="VoiceRegion"/>s.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/voice#list-voice-regions"/>
/// </remarks>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a collection of <see cref="VoiceRegion"/>s.
/// </returns>
Task<IEnumerable<VoiceRegion>> ListVoiceRegionsAsync(CancellationToken cancellationToken = default);

#endregion Voice

#region Webhook

/// <summary>
/// Creates a new <see cref="Webhook"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#create-webhook"/>
/// </remarks>
/// <param name="channelId">
/// The <see cref="Channel"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing the created <see cref="Webhook"/>.
/// </returns>
Task<Webhook> CreateWebhookAsync(Snowflake channelId, CreateWebhookParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets all <see cref="Webhook"/>s in a <see cref="Channel"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#get-channel-webhooks"/>
/// </remarks>
/// <param name="channelId">
/// The <see cref="Channel"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a collection of <see cref="Webhook"/>s.
/// </returns>
Task<IEnumerable<Webhook>> GetChannelWebhooksAsync(Snowflake channelId, CancellationToken cancellationToken = default);

/// <summary>
/// Gets all <see cref="Webhook"/>s in a <see cref="Guild"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#get-guild-webhooks"/>
/// </remarks>
/// <param name="guildId">
/// The <see cref="Guild"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a collection of <see cref="Webhook"/>s.
/// </returns>
Task<IEnumerable<Webhook>> GetGuildWebhooksAsync(Snowflake guildId, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the <see cref="Webhook"/> for the given id.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#get-webhook"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a <see cref="Webhook"/>; or <see langword="null"/> if it does not exist.
/// </returns>
Task<Webhook> GetWebhookAsync(Snowflake webhookId, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the <see cref="Webhook"/> for the given id and token.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#get-webhook-with-token"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing a <see cref="Webhook"/>; or <see langword="null"/> if it does not exist.
/// </returns>
Task<Webhook> GetWebhookAsync(Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies a <see cref="Webhook"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#modify-webhook"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing the updated <see cref="Webhook"/>.
/// </returns>
Task<Webhook> ModifyWebhookAsync(Snowflake webhookId, ModifyWebhookParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies a <see cref="Webhook"/> without requiring authentication.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task containing the updated <see cref="Webhook"/>.
/// </returns>
Task<Webhook> ModifyWebhookAsync(Snowflake webhookId, string webhookToken, ModifyWebhookWithTokenParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes a <see cref="Webhook"/> permanently.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#delete-webhook"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that represents this asynchronous operation.
/// </returns>
Task DeleteWebhookAsync(Snowflake webhookId, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes a <see cref="Webhook"/> permanently without requiring authentication.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that represents this asynchronous operation.
/// </returns>
Task DeleteWebhookAsync(Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default);

/// <summary>
/// Sends a <see cref="Message"/> as a <see cref="Webhook"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#execute-webhook"/>
/// </remarks>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the created <see cref="Message"/>.
/// </returns>
Task<Message> ExecuteWebhookAsync(Snowflake webhookId, string webhookToken, ExecuteWebhookParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Gets a previously-sent <see cref="Webhook"/> <see cref="Message"/> from the same token.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#get-webhook-message"/>
/// </remarks>
/// <param name="messageId">
/// The <see cref="Message"/> identifier.
/// </param>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains a <see cref="Message"/>; or <see langword="null"/> if not found.
/// </returns>
Task<Message> GetWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default);

/// <summary>
/// Edits a previously-sent <see cref="Webhook"/> <see cref="Message"/> from the same token.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#edit-webhook-message"/>
/// </remarks>
/// <param name="messageId">
/// The <see cref="Message"/> identifier.
/// </param>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="args">
/// Parameters to include in the request.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that contains the updated <see cref="Message"/>.
/// </returns>
Task<Message> EditWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, EditWebhookMessageParams args, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes a <see cref="Message"/> that was created by the <see cref="Webhook"/>.
/// </summary>
/// <remarks>
/// <see href="https://discord.com/developers/docs/resources/webhook#delete-webhook-message"/>
/// </remarks>
/// <param name="messageId">
/// The <see cref="Message"/> identifier.
/// </param>
/// <param name="webhookId">
/// The <see cref="Webhook"/> identifier.
/// </param>
/// <param name="webhookToken">
/// The <see cref="Webhook"/> token.
/// </param>
/// <param name="cancellationToken">
/// Cancellation token for the request.
/// </param>
/// <returns>
/// A task that represents this asynchronous operation.
/// </returns>
Task DeleteWebhookMessageAsync(Snowflake messageId, Snowflake webhookId, string webhookToken, CancellationToken cancellationToken = default);

#endregion Webhook
} }
} }

+ 21
- 0
src/Rest/Net/Requests/Channels/CreateDMParams.cs View File

@@ -0,0 +1,21 @@
namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record CreateDMParams
{
/// <summary>
/// The recipient to open a DM channel with.
/// </summary>
public Snowflake RecipientId { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotZero(RecipientId, nameof(RecipientId));
}
}
}

+ 36
- 0
src/Rest/Net/Requests/Channels/CreateStageInstanceParams.cs View File

@@ -0,0 +1,36 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record CreateStageInstanceParams
{
/// <summary>
/// The id of the Stage channel.
/// </summary>
public Snowflake ChannelId { get; set; }

/// <summary>
/// The topic of the Stage instance (1-120 characters).
/// </summary>
public string? Topic { get; set; } // Required property candidate

/// <summary>
/// The privacy level of the Stage instance (default <see cref="PrivacyLevel.GuildOnly"/>).
/// </summary>
public Optional<PrivacyLevel> PrivacyLevel { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotZero(ChannelId, nameof(ChannelId));
Preconditions.NotNull(Topic, nameof(Topic));
Preconditions.LengthAtLeast(Topic, StageInstance.MinStageChannelTopicLength, nameof(Topic));
Preconditions.LengthAtMost(Topic, StageInstance.MaxStageChannelTopicLength, nameof(Topic));
}
}
}

+ 30
- 0
src/Rest/Net/Requests/Channels/ModifyStageInstanceParams.cs View File

@@ -0,0 +1,30 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ModifyStageInstanceParams
{
/// <summary>
/// The topic of the Stage instance (1-120 characters).
/// </summary>
public Optional<string> Topic { get; set; }

/// <summary>
/// The privacy level of the Stage instance.
/// </summary>
public Optional<int> PrivacyLevel { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Topic!, nameof(Topic));
Preconditions.LengthAtLeast(Topic!, StageInstance.MinStageChannelTopicLength, nameof(Topic));
Preconditions.LengthAtMost(Topic!, StageInstance.MaxStageChannelTopicLength, nameof(Topic));
}
}
}

+ 32
- 0
src/Rest/Net/Requests/Guilds/CreateGuildTemplateParams.cs View File

@@ -0,0 +1,32 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record CreateGuildTemplateParams
{
/// <summary>
/// Name of the template (1-100 characters).
/// </summary>
public string? Name { get; set; } // Required property candidate

/// <summary>
/// Description for the template (0-120 characters).
/// </summary>
public Optional<string?> Description { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Name, nameof(Name));
Preconditions.LengthAtLeast(Name, GuildTemplate.MinTemplateNameLength, nameof(Name));
Preconditions.LengthAtMost(Name, GuildTemplate.MaxTemplateNameLength, nameof(Name));
Preconditions.LengthAtLeast(Description, GuildTemplate.MinTemplateDescriptionLength, nameof(Description));
Preconditions.LengthAtMost(Description, GuildTemplate.MaxTemplateDescriptionLength, nameof(Description));
}
}
}

+ 30
- 0
src/Rest/Net/Requests/Guilds/CreateGuildfromGuildTemplateParams.cs View File

@@ -0,0 +1,30 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record CreateGuildfromGuildTemplateParams
{
/// <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>
/// 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));
}
}
}

+ 32
- 0
src/Rest/Net/Requests/Guilds/ModifyGuildTemplateParams.cs View File

@@ -0,0 +1,32 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ModifyGuildTemplateParams
{
/// <summary>
/// Name of the template (1-100 characters).
/// </summary>
public Optional<string> Name { get; set; }

/// <summary>
/// Description for the template (0-120 characters).
/// </summary>
public Optional<string?> Description { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Name!, nameof(Name));
Preconditions.LengthAtLeast(Name!, GuildTemplate.MinTemplateNameLength, nameof(Name));
Preconditions.LengthAtMost(Name!, GuildTemplate.MaxTemplateNameLength, nameof(Name));
Preconditions.LengthAtLeast(Description, GuildTemplate.MinTemplateDescriptionLength, nameof(Description));
Preconditions.LengthAtMost(Description, GuildTemplate.MaxTemplateDescriptionLength, nameof(Description));
}
}
}

+ 25
- 0
src/Rest/Net/Requests/Invites/GetInviteParams.cs View File

@@ -0,0 +1,25 @@
namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record GetInviteParams
{
/// <summary>
/// Whether the invite should contain approximate member counts.
/// </summary>
public Optional<bool> WithCounts { get; set; }

/// <summary>
/// Whether the invite should contain the expiration date.
/// </summary>
public Optional<bool> WithExpiration { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
}
}
}

+ 35
- 0
src/Rest/Net/Requests/Users/GetCurrentUserGuildsParams.cs View File

@@ -0,0 +1,35 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record GetCurrentUserGuildsParams
{
/// <summary>
/// Get guilds before this guild ID.
/// </summary>
public Snowflake Before { get; set; }

/// <summary>
/// Get guilds after this guild ID.
/// </summary>
public Snowflake After { get; set; }

/// <summary>
/// Max number of guilds to return (1-200).
/// </summary>
public int Limit { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotZero(Before, nameof(Before));
Preconditions.AtLeast(Limit, Guild.MinGetGuildsAmount, nameof(Limit));
Preconditions.AtMost(Limit, Guild.MaxGetGuildsAmount, nameof(Limit));
}
}
}

+ 28
- 0
src/Rest/Net/Requests/Users/ModifyCurrentUserParams.cs View File

@@ -0,0 +1,28 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ModifyCurrentUserParams
{
/// <summary>
/// <see cref="User"/>'s username, if changed may cause the <see cref="User"/>'s
/// discriminator to be randomized.
/// </summary>
public Optional<string> Username { get; set; }

/// <summary>
/// If passed, modifies the <see cref="User"/>'s avatar.
/// </summary>
public Optional<Image?> Avatar { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
}
}
}

+ 30
- 0
src/Rest/Net/Requests/Webhooks/CreateWebhookParams.cs View File

@@ -0,0 +1,30 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record CreateWebhookParams
{
/// <summary>
/// Name of the webhook (1-80 characters).
/// </summary>
public string? Name { get; set; } // Required property candidate

/// <summary>
/// Image for the default webhook avatar.
/// </summary>
public Optional<Image?> Avatar { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Name, nameof(Name));
Preconditions.LengthAtLeast(Name, Webhook.MinNameLength, nameof(Name));
Preconditions.LengthAtMost(Name, Webhook.MaxNameLength, nameof(Name));
}
}
}

+ 54
- 0
src/Rest/Net/Requests/Webhooks/EditWebhookMessageParams.cs View File

@@ -0,0 +1,54 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record EditWebhookMessageParams
{
/// <summary>
/// The message contents.
/// </summary>
public Optional<string?> Content { get; set; }

/// <summary>
/// Embedded rich content.
/// </summary>
public Optional<Embed[]?> Embeds { get; set; }

/// <summary>
/// The contents of the file being sent/edited.
/// </summary>
public Optional<MultipartFile?> File { get; set; }

/// <summary>
/// JSON encoded body of non-file params (multipart/form-data only).
/// </summary>
public Optional<EditWebhookMessageParams?> PayloadJson { get; set; } // TODO: Should change this to an easy way to convert to form data.

/// <summary>
/// Allowed mentions for the message.
/// </summary>
public Optional<AllowedMentions?> AllowedMentions { get; set; }

/// <summary>
/// Attached files to keep.
/// </summary>
public Optional<Attachment[]?> Attachments { get; set; }

/// <summary>
/// The components to include with the message.
/// </summary>
public Optional<Component[]?> Components { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.LengthAtMost(Content, Message.MaxContentLength, nameof(Content));
Preconditions.LengthAtMost(Embeds, Message.MaxEmbeds, nameof(Embeds));
}
}
}

+ 78
- 0
src/Rest/Net/Requests/Webhooks/ExecuteWebhookParams.cs View File

@@ -0,0 +1,78 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ExecuteWebhookParams
{
/// <summary>
/// Waits for server confirmation of message send before response, and returns the created message.
/// </summary>
public Optional<bool> Wait { get; set; }

/// <summary>
/// Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived.
/// </summary>
public Optional<Snowflake> ThreadId { get; set; }

/// <summary>
/// The message contents.
/// </summary>
public Optional<string> Content { get; set; }

/// <summary>
/// Override the default username of the webhook.
/// </summary>
public Optional<string> Username { get; set; }

/// <summary>
/// Override the default avatar of the webhook.
/// </summary>
public Optional<string> AvatarUrl { get; set; }

/// <summary>
/// True if this is a TTS message.
/// </summary>
public Optional<bool> Tts { get; set; }

/// <summary>
/// The contents of the file being sent.
/// </summary>
public Optional<MultipartFile> File { get; set; }

/// <summary>
/// Embedded rich content.
/// </summary>
public Optional<Embed[]> Embeds { get; set; }

/// <summary>
/// JSON encoded body of non-file params.
/// </summary>
public Optional<ExecuteWebhookParams> PayloadJson { get; set; }

/// <summary>
/// Allowed mentions for the message.
/// </summary>
public Optional<AllowedMentions> AllowedMentions { get; set; }

/// <summary>
/// The components to include with the message.
/// </summary>
public Optional<Component[]> Components { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotZero(ThreadId, nameof(ThreadId));
Preconditions.LengthAtMost(Content!, Message.MaxContentLength, nameof(Content));
Preconditions.NotNull(Username!, nameof(Username));
Preconditions.LengthAtLeast(Username!, Webhook.MinNameLength, nameof(Username));
Preconditions.LengthAtMost(Username!, Webhook.MaxNameLength, nameof(Username));
Preconditions.LengthAtMost(Embeds!, Message.MaxEmbeds, nameof(Embeds));
}
}
}

+ 36
- 0
src/Rest/Net/Requests/Webhooks/ModifyWebhookParams.cs View File

@@ -0,0 +1,36 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ModifyWebhookParams
{
/// <summary>
/// The default name of the webhook.
/// </summary>
public Optional<string> Name { get; set; }

/// <summary>
/// Image for the default webhook avatar.
/// </summary>
public Optional<Image?> Avatar { get; set; }

/// <summary>
/// The new channel id this webhook should be moved to.
/// </summary>
public Optional<Snowflake> ChannelId { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Name!, nameof(Name));
Preconditions.LengthAtLeast(Name!, Webhook.MinNameLength, nameof(Name));
Preconditions.LengthAtMost(Name!, Webhook.MaxNameLength, nameof(Name));
Preconditions.NotZero(ChannelId, nameof(ChannelId));
}
}
}

+ 30
- 0
src/Rest/Net/Requests/Webhooks/ModifyWebhookWithTokenParams.cs View File

@@ -0,0 +1,30 @@
using Discord.Net.Models;

namespace Discord.Net.Rest
{
/// <summary>
/// Parameters to add to the request.
/// </summary>
public record ModifyWebhookWithTokenParams
{
/// <summary>
/// The default name of the webhook.
/// </summary>
public Optional<string> Name { get; set; }

/// <summary>
/// Image for the default webhook avatar.
/// </summary>
public Optional<Image?> Avatar { get; set; }

/// <summary>
/// Validates the data.
/// </summary>
public void Validate()
{
Preconditions.NotNull(Name!, nameof(Name));
Preconditions.LengthAtLeast(Name!, Webhook.MinNameLength, nameof(Name));
Preconditions.LengthAtMost(Name!, Webhook.MaxNameLength, nameof(Name));
}
}
}

Loading…
Cancel
Save