Browse Source

Merge branch 'dev' into feature/text-in-voice

pull/2269/head
Quin Lynch GitHub 3 years ago
parent
commit
f909a5eb27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 147 additions and 99 deletions
  1. +2
    -0
      .github/FUNDING.yml
  2. +13
    -0
      CHANGELOG.md
  3. +1
    -1
      Discord.Net.targets
  4. +1
    -1
      docs/docfx.json
  5. +2
    -0
      src/Discord.Net.Commands/Discord.Net.Commands.csproj
  6. +3
    -3
      src/Discord.Net.Commands/Results/MatchResult.cs
  7. +2
    -0
      src/Discord.Net.Core/Discord.Net.Core.csproj
  8. +1
    -0
      src/Discord.Net.Core/DiscordErrorCode.cs
  9. +0
    -1
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  10. +1
    -1
      src/Discord.Net.Core/Entities/Guilds/IGuildScheduledEvent.cs
  11. +1
    -1
      src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs
  12. +1
    -1
      src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs
  13. +5
    -5
      src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs
  14. +4
    -4
      src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs
  15. +13
    -2
      src/Discord.Net.Core/Entities/Messages/MessageReference.cs
  16. +1
    -1
      src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs
  17. +3
    -3
      src/Discord.Net.Core/Entities/Users/IGuildUser.cs
  18. +1
    -1
      src/Discord.Net.Core/Utils/UrlValidation.cs
  19. +3
    -3
      src/Discord.Net.Interactions/Attributes/AutocompleteAttribute.cs
  20. +0
    -2
      src/Discord.Net.Interactions/Attributes/Modals/ModalInputAttribute.cs
  21. +1
    -1
      src/Discord.Net.Interactions/Attributes/Modals/ModalTextInputAttribute.cs
  22. +2
    -2
      src/Discord.Net.Interactions/Attributes/Preconditions/RequireUserPermissionAttribute.cs
  23. +1
    -1
      src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs
  24. +1
    -1
      src/Discord.Net.Interactions/Builders/Modals/Inputs/TextInputComponentBuilder.cs
  25. +1
    -1
      src/Discord.Net.Interactions/Builders/Modals/ModalBuilder.cs
  26. +2
    -1
      src/Discord.Net.Interactions/Builders/ModuleBuilder.cs
  27. +1
    -1
      src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs
  28. +3
    -1
      src/Discord.Net.Interactions/Discord.Net.Interactions.csproj
  29. +1
    -2
      src/Discord.Net.Interactions/InteractionContext.cs
  30. +6
    -6
      src/Discord.Net.Interactions/InteractionModuleBase.cs
  31. +15
    -10
      src/Discord.Net.Interactions/InteractionService.cs
  32. +2
    -2
      src/Discord.Net.Interactions/RestInteractionModuleBase.cs
  33. +1
    -1
      src/Discord.Net.Interactions/Results/TypeConverterResult.cs
  34. +3
    -0
      src/Discord.Net.Rest/API/Common/MessageReference.cs
  35. +2
    -0
      src/Discord.Net.Rest/Discord.Net.Rest.csproj
  36. +2
    -1
      src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
  37. +1
    -1
      src/Discord.Net.Rest/Entities/Roles/RestRole.cs
  38. +1
    -0
      src/Discord.Net.Rest/Extensions/EntityExtensions.cs
  39. +2
    -0
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
  40. +3
    -1
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  41. +0
    -1
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
  42. +2
    -1
      src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs
  43. +2
    -0
      src/Discord.Net.Webhook/Discord.Net.Webhook.csproj
  44. +34
    -34
      src/Discord.Net/Discord.Net.nuspec

+ 2
- 0
.github/FUNDING.yml View File

@@ -1 +1,3 @@
github: quinchs
open_collective: discordnet
custom: https://paypal.me/quinchs

+ 13
- 0
CHANGELOG.md View File

@@ -1,5 +1,18 @@
# Changelog

## [3.6.1] - 2022-04-30
### Added
- #2272 add 50080 Error code (503e720)

### Fixed
- #2267 Permissions v2 Invalid Operation Exception (a8f6075)
- #2271 null user on interaction without bot scope (f2bb55e)
- #2274 Implement fix for Custom Id Segments NRE (0d74c5c)

### Misc
- 3.6.0 (27226f0)


## [3.6.0] - 2022-04-28
### Added
- #2136 Passing CustomId matches into contexts (4ce1801)


+ 1
- 1
Discord.Net.targets View File

@@ -1,6 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>3.6.0</VersionPrefix>
<VersionPrefix>3.6.1</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Discord.Net Contributors</Authors>
<PackageTags>discord;discordapp</PackageTags>


+ 1
- 1
docs/docfx.json View File

@@ -60,7 +60,7 @@
"overwrite": "_overwrites/**/**.md",
"globalMetadata": {
"_appTitle": "Discord.Net Documentation",
"_appFooter": "Discord.Net (c) 2015-2022 3.6.0",
"_appFooter": "Discord.Net (c) 2015-2022 3.6.1",
"_enableSearch": true,
"_appLogoPath": "marketing/logo/SVG/Logomark Purple.svg",
"_appFaviconPath": "favicon.ico"


+ 2
- 0
src/Discord.Net.Commands/Discord.Net.Commands.csproj View File

@@ -7,6 +7,8 @@
<Description>A Discord.Net extension adding support for bot commands.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />


+ 3
- 3
src/Discord.Net.Commands/Results/MatchResult.cs View File

@@ -1,4 +1,4 @@
using System;
using System;

namespace Discord.Commands
{
@@ -12,7 +12,7 @@ namespace Discord.Commands
/// <summary>
/// Gets on which pipeline stage the command may have matched or failed.
/// </summary>
public IResult? Pipeline { get; }
public IResult Pipeline { get; }

/// <inheritdoc />
public CommandError? Error { get; }
@@ -21,7 +21,7 @@ namespace Discord.Commands
/// <inheritdoc />
public bool IsSuccess => !Error.HasValue;

private MatchResult(CommandMatch? match, IResult? pipeline, CommandError? error, string errorReason)
private MatchResult(CommandMatch? match, IResult pipeline, CommandError? error, string errorReason)
{
Match = match;
Error = error;


+ 2
- 0
src/Discord.Net.Core/Discord.Net.Core.csproj View File

@@ -7,6 +7,8 @@
<Description>The core components for the Discord.Net library.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />


+ 1
- 0
src/Discord.Net.Core/DiscordErrorCode.cs View File

@@ -152,6 +152,7 @@ namespace Discord
InvalidMessageType = 50068,
PaymentSourceRequiredForGift = 50070,
CannotDeleteRequiredCommunityChannel = 50074,
CannotEditStickersWithinAMessage = 50080,
InvalidSticker = 50081,
CannotExecuteOnArchivedThread = 50083,
InvalidThreadNotificationSettings = 50084,


+ 0
- 1
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -1173,7 +1173,6 @@ namespace Discord
/// in order to use this property.
/// </remarks>
/// </param>
/// <param name="speakers">A collection of speakers for the event.</param>
/// <param name="location">The location of the event; links are supported</param>
/// <param name="coverImage">The optional banner image for the event.</param>
/// <param name="options">The options to be used when sending the request.</param>


+ 1
- 1
src/Discord.Net.Core/Entities/Guilds/IGuildScheduledEvent.cs View File

@@ -89,7 +89,7 @@ namespace Discord
/// Gets this events banner image url.
/// </summary>
/// <param name="format">The format to return.</param>
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048.
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048.</param>
/// <returns>The cover images url.</returns>
string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024);



+ 1
- 1
src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs View File

@@ -56,7 +56,7 @@ namespace Discord
Number = 10,

/// <summary>
/// A <see cref="Discord.Attachment"/>.
/// A <see cref="IAttachment"/>.
/// </summary>
Attachment = 11
}


+ 1
- 1
src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs View File

@@ -55,7 +55,7 @@ namespace Discord
string UserLocale { get; }

/// <summary>
/// Gets the preferred locale of the guild this interaction was executed in. <see cref="null"/> if not executed in a guild.
/// Gets the preferred locale of the guild this interaction was executed in. <see langword="null"/> if not executed in a guild.
/// </summary>
/// <remarks>
/// Non-community guilds (With no locale setting available) will have en-US as the default value sent by Discord.


+ 5
- 5
src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs View File

@@ -1194,9 +1194,9 @@ namespace Discord
/// <summary>
/// Gets or sets the default value of the text input.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException"><see cref="Value.Length"/> is less than 0.</exception>
/// <exception cref="ArgumentOutOfRangeException"><see cref="Value"/>.Length is less than 0.</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <see cref="Value.Length"/> is greater than <see cref="LargestMaxLength"/> or <see cref="MaxLength"/>.
/// <see cref="Value"/>.Length is greater than <see cref="LargestMaxLength"/> or <see cref="MaxLength"/>.
/// </exception>
public string Value
{
@@ -1306,18 +1306,18 @@ namespace Discord
/// <summary>
/// Sets the minimum length of the current builder.
/// </summary>
/// <param name="placeholder">The value to set.</param>
/// <param name="minLength">The value to set.</param>
/// <returns>The current builder. </returns>
public TextInputBuilder WithMinLength(int minLength)
{
MinLength = minLength;
return this;
}
/// <summary>
/// Sets the maximum length of the current builder.
/// </summary>
/// <param name="placeholder">The value to set.</param>
/// <param name="maxLength">The value to set.</param>
/// <returns>The current builder. </returns>
public TextInputBuilder WithMaxLength(int maxLength)
{


+ 4
- 4
src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs View File

@@ -64,18 +64,18 @@ namespace Discord
/// <summary>
/// Sets the custom id of the current modal.
/// </summary>
/// <param name="title">The value to set the custom id to.</param>
/// <param name="customId">The value to set the custom id to.</param>
/// <returns>The current builder.</returns>
public ModalBuilder WithCustomId(string customId)
{
CustomId = customId;
return this;
}
/// <summary>
/// Adds a component to the current builder.
/// </summary>
/// <param name="title">The component to add.</param>
/// <param name="component">The component to add.</param>
/// <returns>The current builder.</returns>
public ModalBuilder AddTextInput(TextInputBuilder component)
{
@@ -213,7 +213,7 @@ namespace Discord
/// Adds a <see cref="TextInputBuilder"/> to the <see cref="ModalComponentBuilder"/> at the specific row.
/// If the row cannot accept the component then it will add it to a row that can.
/// </summary>
/// <param name="text">The <see cref="TextInputBuilder"> to add.</param>
/// <param name="text">The <see cref="TextInputBuilder"/> to add.</param>
/// <param name="row">The row to add the text input.</param>
/// <exception cref="InvalidOperationException">There are no more rows to add a text input to.</exception>
/// <exception cref="ArgumentException"><paramref name="row"/> must be less than <see cref="MaxActionRowCount"/>.</exception>


+ 13
- 2
src/Discord.Net.Core/Entities/Messages/MessageReference.cs View File

@@ -27,6 +27,12 @@ namespace Discord
/// </summary>
public Optional<ulong> GuildId { get; internal set; }

/// <summary>
/// Gets whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
/// Defaults to true.
/// </summary>
public Optional<bool> FailIfNotExists { get; internal set; }

/// <summary>
/// Initializes a new instance of the <see cref="MessageReference"/> class.
/// </summary>
@@ -39,16 +45,21 @@ namespace Discord
/// <param name="guildId">
/// The ID of the guild that will be referenced. It will be validated if sent.
/// </param>
public MessageReference(ulong? messageId = null, ulong? channelId = null, ulong? guildId = null)
/// <param name="failIfNotExists">
/// Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message. Defaults to true.
/// </param>
public MessageReference(ulong? messageId = null, ulong? channelId = null, ulong? guildId = null, bool? failIfNotExists = null)
{
MessageId = messageId ?? Optional.Create<ulong>();
InternalChannelId = channelId ?? Optional.Create<ulong>();
GuildId = guildId ?? Optional.Create<ulong>();
FailIfNotExists = failIfNotExists ?? Optional.Create<bool>();
}

private string DebuggerDisplay
=> $"Channel ID: ({ChannelId}){(GuildId.IsSpecified ? $", Guild ID: ({GuildId.Value})" : "")}" +
$"{(MessageId.IsSpecified ? $", Message ID: ({MessageId.Value})" : "")}";
$"{(MessageId.IsSpecified ? $", Message ID: ({MessageId.Value})" : "")}" +
$"{(FailIfNotExists.IsSpecified ? $", FailIfNotExists: ({FailIfNotExists.Value})" : "")}";

public override string ToString()
=> DebuggerDisplay;


+ 1
- 1
src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs View File

@@ -79,7 +79,7 @@ namespace Discord
/// Sets a timestamp how long a user should be timed out for.
/// </summary>
/// <remarks>
/// <see cref="null"/> or a time in the past to clear a currently existing timeout.
/// <see langword="null"/> or a time in the past to clear a currently existing timeout.
/// </remarks>
public Optional<DateTimeOffset?> TimedOutUntil { get; set; }
}


+ 3
- 3
src/Discord.Net.Core/Entities/Users/IGuildUser.cs View File

@@ -104,7 +104,7 @@ namespace Discord
/// Gets the date and time that indicates if and for how long a user has been timed out.
/// </summary>
/// <remarks>
/// <see cref="null"/> or a timestamp in the past if the user is not timed out.
/// <see langword="null"/> or a timestamp in the past if the user is not timed out.
/// </remarks>
/// <returns>
/// A <see cref="DateTimeOffset"/> indicating how long the user will be timed out for.
@@ -116,7 +116,7 @@ namespace Discord
/// </summary>
/// <example>
/// <para>The following example checks if the current user has the ability to send a message with attachment in
/// this channel; if so, uploads a file via <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.</para>
/// this channel; if so, uploads a file via <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>.</para>
/// <code language="cs">
/// if (currentUser?.GetPermissions(targetChannel)?.AttachFiles)
/// await targetChannel.SendFileAsync("fortnite.png");
@@ -151,7 +151,7 @@ namespace Discord
/// If the user does not have a guild avatar, this will be the user's regular avatar.
/// </remarks>
/// <param name="format">The format to return.</param>
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048.
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048.</param>
/// <returns>
/// A string representing the URL of the displayed avatar for this user. <see langword="null"/> if the user does not have an avatar in place.
/// </returns>


+ 1
- 1
src/Discord.Net.Core/Utils/UrlValidation.cs View File

@@ -23,7 +23,7 @@ namespace Discord.Utils

/// <summary>
/// Not full URL validation right now. Just Ensures the protocol is either http, https, or discord
/// <see cref="Validate(string)"/> should be used everything other than url buttons.
/// <see cref="Validate(string, bool)"/> should be used everything other than url buttons.
/// </summary>
/// <param name="url">The URL to validate before sending to discord.</param>
/// <exception cref="InvalidOperationException">A URL must include a protocol (either http, https, or discord).</exception>


+ 3
- 3
src/Discord.Net.Interactions/Attributes/AutocompleteAttribute.cs View File

@@ -3,7 +3,7 @@ using System;
namespace Discord.Interactions
{
/// <summary>
/// Set the <see cref="ApplicationCommandOptionProperties.Autocomplete"/> to <see langword="true"/>.
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class AutocompleteAttribute : Attribute
@@ -14,7 +14,7 @@ namespace Discord.Interactions
public Type AutocompleteHandlerType { get; }

/// <summary>
/// Set the <see cref="ApplicationCommandOptionProperties.Autocomplete"/> to <see langword="true"/> and define a <see cref="AutocompleteHandler"/> to handle
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/> and define a <see cref="AutocompleteHandler"/> to handle
/// Autocomplete interactions targeting the parameter this <see cref="Attribute"/> is applied to.
/// </summary>
/// <remarks>
@@ -29,7 +29,7 @@ namespace Discord.Interactions
}

/// <summary>
/// Set the <see cref="ApplicationCommandOptionProperties.Autocomplete"/> to <see langword="true"/> without specifying a <see cref="AutocompleteHandler"/>.
/// Set the <see cref="ApplicationCommandOptionProperties.IsAutocomplete"/> to <see langword="true"/> without specifying a <see cref="AutocompleteHandler"/>.
/// </summary>
public AutocompleteAttribute() { }
}


+ 0
- 2
src/Discord.Net.Interactions/Attributes/Modals/ModalInputAttribute.cs View File

@@ -21,9 +21,7 @@ namespace Discord.Interactions
/// <summary>
/// Create a new <see cref="ModalInputAttribute"/>.
/// </summary>
/// <param name="label">The label of the input.</param>
/// <param name="customId">The custom id of the input.</param>
/// <param name="required">Whether the user is required to input a value.></param>
protected ModalInputAttribute(string customId)
{
CustomId = customId;


+ 1
- 1
src/Discord.Net.Interactions/Attributes/Modals/ModalTextInputAttribute.cs View File

@@ -36,7 +36,7 @@ namespace Discord.Interactions
/// <summary>
/// Create a new <see cref="ModalTextInputAttribute"/>.
/// </summary>
/// <param name="customId"The custom id of the text input.></param>
/// <param name="customId">The custom id of the text input.></param>
/// <param name="style">The style of the text input.</param>
/// <param name="placeholder">The placeholder of the text input.</param>
/// <param name="minLength">The minimum length of the text input's content.</param>


+ 2
- 2
src/Discord.Net.Interactions/Attributes/Preconditions/RequireUserPermissionAttribute.cs View File

@@ -29,7 +29,7 @@ namespace Discord.Interactions
/// <remarks>
/// This precondition will always fail if the command is being invoked in a <see cref="IPrivateChannel"/>.
/// </remarks>
/// <param name="permission">
/// <param name="guildPermission">
/// The <see cref="Discord.GuildPermission" /> that the user must have. Multiple permissions can be
/// specified by ORing the permissions together.
/// </param>
@@ -41,7 +41,7 @@ namespace Discord.Interactions
/// <summary>
/// Requires that the user invoking the command to have a specific <see cref="Discord.ChannelPermission"/>.
/// </summary>
/// <param name="permission">
/// <param name="channelPermission">
/// The <see cref="Discord.ChannelPermission"/> that the user must have. Multiple permissions can be
/// specified by ORing the permissions together.
/// </param>


+ 1
- 1
src/Discord.Net.Interactions/Builders/Commands/SlashCommandBuilder.cs View File

@@ -56,7 +56,7 @@ namespace Discord.Interactions.Builders
/// <summary>
/// Sets <see cref="DefaultPermission"/>.
/// </summary>
/// <param name="defaultPermision">New value of the <see cref="DefaultPermission"/>.</param>
/// <param name="permission">New value of the <see cref="DefaultPermission"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>


+ 1
- 1
src/Discord.Net.Interactions/Builders/Modals/Inputs/TextInputComponentBuilder.cs View File

@@ -41,7 +41,7 @@ namespace Discord.Interactions.Builders
/// <summary>
/// Sets <see cref="Style"/>.
/// </summary>
/// <param name="style">New value of the <see cref="SetValue(string)"/>.</param>
/// <param name="style">New value of the <see cref="Style"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>


+ 1
- 1
src/Discord.Net.Interactions/Builders/Modals/ModalBuilder.cs View File

@@ -64,7 +64,7 @@ namespace Discord.Interactions.Builders
}

/// <summary>
/// Adds text components to <see cref="TextComponents"/>.
/// Adds text components to <see cref="Components"/>.
/// </summary>
/// <param name="configure">Text Component builder factory.</param>
/// <returns>


+ 2
- 1
src/Discord.Net.Interactions/Builders/ModuleBuilder.cs View File

@@ -357,7 +357,8 @@ namespace Discord.Interactions.Builders
return this;

}

/// <summary>
/// Adds a modal command builder to <see cref="ModalCommands"/>.
/// </summary>
/// <param name="configure"><see cref="ModalCommands"/> factory.</param>


+ 1
- 1
src/Discord.Net.Interactions/Builders/Parameters/ParameterBuilder.cs View File

@@ -122,7 +122,7 @@ namespace Discord.Interactions.Builders
/// <summary>
/// Adds preconditions to <see cref="Preconditions"/>
/// </summary>
/// <param name="preconditions">New attributes to be added to <see cref="Preconditions"/>.</param>
/// <param name="attributes">New attributes to be added to <see cref="Preconditions"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>


+ 3
- 1
src/Discord.Net.Interactions/Discord.Net.Interactions.csproj View File

@@ -7,8 +7,10 @@
<RootNamespace>Discord.Interactions</RootNamespace>
<AssemblyName>Discord.Net.Interactions</AssemblyName>
<Description>A Discord.Net extension adding support for Application Commands.</Description>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
<ProjectReference Include="..\Discord.Net.Rest\Discord.Net.Rest.csproj" />


+ 1
- 2
src/Discord.Net.Interactions/InteractionContext.cs View File

@@ -24,8 +24,7 @@ namespace Discord.Interactions
/// </summary>
/// <param name="client">The underlying client.</param>
/// <param name="interaction">The underlying interaction.</param>
/// <param name="user"><see cref="IUser"/> who executed the command.</param>
/// <param name="channel"><see cref="ISocketMessageChannel"/> the command originated from.</param>
/// <param name="channel"><see cref="IMessageChannel"/> the command originated from.</param>
public InteractionContext(IDiscordClient client, IDiscordInteraction interaction, IMessageChannel channel = null)
{
Client = client;


+ 6
- 6
src/Discord.Net.Interactions/InteractionModuleBase.cs View File

@@ -45,7 +45,7 @@ namespace Discord.Interactions
protected virtual async Task DeferAsync(bool ephemeral = false, RequestOptions options = null) =>
await Context.Interaction.DeferAsync(ephemeral, options).ConfigureAwait(false);

/// <inheritdoc cref="IDiscordInteraction.RespondAsync(string, Embed[], bool, bool, AllowedMentions, RequestOptions, MessageComponent, Embed)"/>
/// <inheritdoc cref="IDiscordInteraction.RespondAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)"/>
protected virtual async Task RespondAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null) =>
await Context.Interaction.RespondAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
@@ -70,7 +70,7 @@ namespace Discord.Interactions
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null)
=> Context.Interaction.RespondWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options);

/// <inheritdoc cref="IDiscordInteraction.FollowupAsync(string, Embed[], bool, bool, AllowedMentions, RequestOptions, MessageComponent, Embed)"/>
/// <inheritdoc cref="IDiscordInteraction.FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions)"/>
protected virtual async Task<IUserMessage> FollowupAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false,
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null) =>
await Context.Interaction.FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
@@ -95,7 +95,7 @@ namespace Discord.Interactions
AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null)
=> Context.Interaction.FollowupWithFilesAsync(attachments, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options);

/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[])"/>
/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
protected virtual async Task<IUserMessage> ReplyAsync (string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null,
AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null) =>
await Context.Channel.SendMessageAsync(text, false, embed, options, allowedMentions, messageReference, components).ConfigureAwait(false);
@@ -118,9 +118,9 @@ namespace Discord.Interactions
/// <inheritdoc cref="IDiscordInteraction.RespondWithModalAsync(Modal, RequestOptions)"/>
protected virtual async Task RespondWithModalAsync(Modal modal, RequestOptions options = null) => await Context.Interaction.RespondWithModalAsync(modal);
/// <inheritdoc cref="IDiscordInteractionExtentions.RespondWithModalAsync(IDiscordInteraction, IModal, RequestOptions)"/>
protected virtual async Task RespondWithModalAsync<T>(string customId, RequestOptions options = null) where T : class, IModal
=> await Context.Interaction.RespondWithModalAsync<T>(customId, options);
/// <inheritdoc cref="IDiscordInteractionExtentions.RespondWithModalAsync{T}(IDiscordInteraction, string, RequestOptions, Action{ModalBuilder})"/>
protected virtual async Task RespondWithModalAsync<TModal>(string customId, RequestOptions options = null) where TModal : class, IModal
=> await Context.Interaction.RespondWithModalAsync<TModal>(customId, options);

//IInteractionModuleBase



+ 15
- 10
src/Discord.Net.Interactions/InteractionService.cs View File

@@ -421,7 +421,7 @@ namespace Discord.Interactions
/// </summary>
/// <remarks>
/// Commands will be registered as standalone commands, if you want the <see cref="GroupAttribute"/> to take effect,
/// use <see cref="AddModulesToGuildAsync(IGuild, ModuleInfo[])"/>. Registering a commands without group names might cause the command traversal to fail.
/// use <see cref="AddModulesToGuildAsync(IGuild, bool, ModuleInfo[])"/>. Registering a commands without group names might cause the command traversal to fail.
/// </remarks>
/// <param name="guild">The target guild.</param>
/// <param name="commands">Commands to be registered to Discord.</param>
@@ -517,7 +517,7 @@ namespace Discord.Interactions
/// </summary>
/// <remarks>
/// Commands will be registered as standalone commands, if you want the <see cref="GroupAttribute"/> to take effect,
/// use <see cref="AddModulesToGuildAsync(IGuild, ModuleInfo[])"/>. Registering a commands without group names might cause the command traversal to fail.
/// use <see cref="AddModulesToGuildAsync(IGuild, bool, ModuleInfo[])"/>. Registering a commands without group names might cause the command traversal to fail.
/// </remarks>
/// <param name="commands">Commands to be registered to Discord.</param>
/// <returns>
@@ -834,11 +834,16 @@ namespace Discord.Interactions
if (!searchResult.Command.SupportsWildCards || context is not IRouteMatchContainer matchContainer)
return;

var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length];
for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++)
matches[i] = new RouteSegmentMatch(searchResult.RegexCaptureGroups[i]);
if (searchResult.RegexCaptureGroups?.Length > 0)
{
var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length];
for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++)
matches[i] = new RouteSegmentMatch(searchResult.RegexCaptureGroups[i]);

matchContainer.SetSegmentMatches(matches);
matchContainer.SetSegmentMatches(matches);
}
else
matchContainer.SetSegmentMatches(Array.Empty<RouteSegmentMatch>());
}

internal TypeConverter GetTypeConverter(Type type, IServiceProvider services = null)
@@ -960,7 +965,7 @@ namespace Discord.Interactions
/// Removes a type reader for the given type.
/// </summary>
/// <remarks>
/// Removing a <see cref="TypeReader"/> from the <see cref="CommandService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// Removing a <see cref="TypeReader"/> from the <see cref="InteractionService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// You need to reload the modules for the changes to take effect.
/// </remarks>
/// <param name="type">The type to remove the reader from.</param>
@@ -973,7 +978,7 @@ namespace Discord.Interactions
/// Removes a generic type reader from the type <typeparamref name="T"/>.
/// </summary>
/// <remarks>
/// Removing a <see cref="TypeReader"/> from the <see cref="CommandService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// Removing a <see cref="TypeReader"/> from the <see cref="InteractionService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// You need to reload the modules for the changes to take effect.
/// </remarks>
/// <typeparam name="T">The type to remove the readers from.</typeparam>
@@ -986,7 +991,7 @@ namespace Discord.Interactions
/// Removes a generic type reader from the given type.
/// </summary>
/// <remarks>
/// Removing a <see cref="TypeReader"/> from the <see cref="CommandService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// Removing a <see cref="TypeReader"/> from the <see cref="InteractionService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// You need to reload the modules for the changes to take effect.
/// </remarks>
/// <param name="type">The type to remove the reader from.</param>
@@ -999,7 +1004,7 @@ namespace Discord.Interactions
/// Serialize an object using a <see cref="TypeReader"/> into a <see cref="string"/> to be placed in a Component CustomId.
/// </summary>
/// <remarks>
/// Removing a <see cref="TypeReader"/> from the <see cref="CommandService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// Removing a <see cref="TypeReader"/> from the <see cref="InteractionService"/> will not dereference the <see cref="TypeReader"/> from the loaded module/command instances.
/// You need to reload the modules for the changes to take effect.
/// </remarks>
/// <typeparam name="T">Type of the object to be serialized.</typeparam>


+ 2
- 2
src/Discord.Net.Interactions/RestInteractionModuleBase.cs View File

@@ -87,12 +87,12 @@ namespace Discord.Interactions
await InteractionService._restResponseCallback(Context, payload).ConfigureAwait(false);
}

protected override async Task RespondWithModalAsync<T>(string customId, RequestOptions options = null)
protected override async Task RespondWithModalAsync<TModal>(string customId, RequestOptions options = null)
{
if (Context.Interaction is not RestInteraction restInteraction)
throw new InvalidOperationException($"Invalid interaction type. Interaction must be a type of {nameof(RestInteraction)} in order to execute this method");

var payload = restInteraction.RespondWithModal<T>(customId, options);
var payload = restInteraction.RespondWithModal<TModal>(customId, options);

if (Context is IRestInteractionContext restContext && restContext.InteractionResponseCallback != null)
await restContext.InteractionResponseCallback.Invoke(payload).ConfigureAwait(false);


+ 1
- 1
src/Discord.Net.Interactions/Results/TypeConverterResult.cs View File

@@ -3,7 +3,7 @@ using System;
namespace Discord.Interactions
{
/// <summary>
/// Represents a result type for <see cref="TypeConverter.ReadAsync(IInteractionContext, WebSocket.SocketSlashCommandDataOption, IServiceProvider)"/>.
/// Represents a result type for <see cref="TypeConverter.ReadAsync(IInteractionContext, IApplicationCommandInteractionDataOption, IServiceProvider)"/>.
/// </summary>
public struct TypeConverterResult : IResult
{


+ 3
- 0
src/Discord.Net.Rest/API/Common/MessageReference.cs View File

@@ -12,5 +12,8 @@ namespace Discord.API

[JsonProperty("guild_id")]
public Optional<ulong> GuildId { get; set; }

[JsonProperty("fail_if_not_exists")]
public Optional<bool> FailIfNotExists { get; set; }
}
}

+ 2
- 0
src/Discord.Net.Rest/Discord.Net.Rest.csproj View File

@@ -7,6 +7,8 @@
<Description>A core Discord.Net library containing the REST client and models.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />


+ 2
- 1
src/Discord.Net.Rest/Entities/Messages/RestMessage.cs View File

@@ -144,7 +144,8 @@ namespace Discord.Rest
{
GuildId = model.Reference.Value.GuildId,
InternalChannelId = model.Reference.Value.ChannelId,
MessageId = model.Reference.Value.MessageId
MessageId = model.Reference.Value.MessageId,
FailIfNotExists = model.Reference.Value.FailIfNotExists
};
}



+ 1
- 1
src/Discord.Net.Rest/Entities/Roles/RestRole.cs View File

@@ -25,7 +25,7 @@ namespace Discord.Rest
public string Name { get; private set; }
/// <inheritdoc />
public string Icon { get; private set; }
/// <inheritdoc/>
/// <inheritdoc />
public Emoji Emoji { get; private set; }
/// <inheritdoc />
public GuildPermissions Permissions { get; private set; }


+ 1
- 0
src/Discord.Net.Rest/Extensions/EntityExtensions.cs View File

@@ -87,6 +87,7 @@ namespace Discord.Rest
ChannelId = entity.InternalChannelId,
GuildId = entity.GuildId,
MessageId = entity.MessageId,
FailIfNotExists = entity.FailIfNotExists
};
}
public static IEnumerable<string> EnumerateMentionTypes(this AllowedMentionTypes mentionTypes)


+ 2
- 0
src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj View File

@@ -8,6 +8,8 @@
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />


+ 3
- 1
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -2331,7 +2331,9 @@ namespace Discord.WebSocket

SocketUser user = data.User.IsSpecified
? State.GetOrAddUser(data.User.Value.Id, (_) => SocketGlobalUser.Create(this, State, data.User.Value))
: guild?.AddOrUpdateUser(data.Member.Value); // null if the bot scope isn't set, so the guild cannot be retrieved.
: guild != null
? guild.AddOrUpdateUser(data.Member.Value) // null if the bot scope isn't set, so the guild cannot be retrieved.
: State.GetOrAddUser(data.Member.Value.User.Id, (_) => SocketGlobalUser.Create(this, State, data.Member.Value.User));

SocketChannel channel = null;
if(data.ChannelId.IsSpecified)


+ 0
- 1
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -1291,7 +1291,6 @@ namespace Discord.WebSocket
/// in order to use this property.
/// </remarks>
/// </param>
/// <param name="speakers">A collection of speakers for the event.</param>
/// <param name="location">The location of the event; links are supported</param>
/// <param name="coverImage">The optional banner image for the event.</param>
/// <param name="options">The options to be used when sending the request.</param>


+ 2
- 1
src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs View File

@@ -182,7 +182,8 @@ namespace Discord.WebSocket
{
GuildId = model.Reference.Value.GuildId,
InternalChannelId = model.Reference.Value.ChannelId,
MessageId = model.Reference.Value.MessageId
MessageId = model.Reference.Value.MessageId,
FailIfNotExists = model.Reference.Value.FailIfNotExists
};
}



+ 2
- 0
src/Discord.Net.Webhook/Discord.Net.Webhook.csproj View File

@@ -6,6 +6,8 @@
<RootNamespace>Discord.Webhook</RootNamespace>
<Description>A core Discord.Net library containing the Webhook client and models.</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />


+ 34
- 34
src/Discord.Net/Discord.Net.nuspec View File

@@ -2,57 +2,57 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Discord.Net</id>
<version>3.6.0$suffix$</version>
<version>3.6.1$suffix$</version>
<title>Discord.Net</title>
<authors>Discord.Net Contributors</authors>
<owners>foxbot</owners>
<description>An asynchronous API wrapper for Discord. This metapackage includes all of the optional Discord.Net components.</description>
<tags>discord;discordapp</tags>
<projectUrl>https://github.com/RogueException/Discord.Net</projectUrl>
<projectUrl>https://github.com/discord-net/Discord.Net</projectUrl>
<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</iconUrl>
<iconUrl>https://github.com/discord-net/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</iconUrl>
<dependencies>
<group targetFramework="net6.0">
<dependency id="Discord.Net.Core" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.0$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Core" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.1$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.1$suffix$" />
</group>
<group targetFramework="net5.0">
<dependency id="Discord.Net.Core" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.0$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Core" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.1$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.1$suffix$" />
</group>
<group targetFramework="net461">
<dependency id="Discord.Net.Core" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.0$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Core" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.1$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.1$suffix$" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="Discord.Net.Core" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.0$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Core" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.1$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.1$suffix$" />
</group>
<group targetFramework="netstandard2.1">
<dependency id="Discord.Net.Core" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.0$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.0$suffix$" />
<dependency id="Discord.Net.Core" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Rest" version="3.6.1$suffix$" />
<dependency id="Discord.Net.WebSocket" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Commands" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Webhook" version="3.6.1$suffix$" />
<dependency id="Discord.Net.Interactions" version="3.6.1$suffix$" />
</group>
</dependencies>
</metadata>
</package>
</package>

Loading…
Cancel
Save