Browse Source

Merge remote-tracking branch 'upstream/dev' into dev

pull/926/head
Acid Chicken (硫酸鶏) 7 years ago
parent
commit
3be8e40d38
No known key found for this signature in database GPG Key ID: E292DBE5D23A5846
100 changed files with 249 additions and 49 deletions
  1. +44
    -0
      CONTRIBUTING.md
  2. +1
    -16
      Discord.Net.sln
  3. +2
    -2
      Discord.Net.targets
  4. +2
    -2
      README.md
  5. +1
    -2
      appveyor.yml
  6. +3
    -3
      docs/guides/commands/commands.md
  7. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/AuthenticateParams.cs
  8. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/AuthenticateResponse.cs
  9. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/AuthorizeParams.cs
  10. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/AuthorizeResponse.cs
  11. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/Channel.cs
  12. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/ChannelSubscriptionParams.cs
  13. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/ChannelSummary.cs
  14. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/ErrorEvent.cs
  15. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/ExtendedVoiceState.cs
  16. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetChannelParams.cs
  17. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetChannelsParams.cs
  18. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetChannelsResponse.cs
  19. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetGuildParams.cs
  20. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetGuildsParams.cs
  21. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GetGuildsResponse.cs
  22. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/Guild.cs
  23. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GuildMember.cs
  24. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GuildStatusEvent.cs
  25. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GuildSubscriptionParams.cs
  26. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/GuildSummary.cs
  27. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/Message.cs
  28. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/MessageEvent.cs
  29. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/Pan.cs
  30. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/ReadyEvent.cs
  31. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/RpcConfig.cs
  32. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/SelectChannelParams.cs
  33. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/SetLocalVolumeParams.cs
  34. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/SetLocalVolumeResponse.cs
  35. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/SpeakingEvent.cs
  36. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/SubscriptionResponse.cs
  37. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/UserVoiceSettings.cs
  38. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/VoiceDevice.cs
  39. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/VoiceDeviceSettings.cs
  40. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/VoiceMode.cs
  41. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/VoiceSettings.cs
  42. +0
    -0
      experiment/Discord.Net.Rpc/API/Rpc/VoiceShortcut.cs
  43. +0
    -0
      experiment/Discord.Net.Rpc/API/RpcFrame.cs
  44. +0
    -0
      experiment/Discord.Net.Rpc/AssemblyInfo.cs
  45. +0
    -0
      experiment/Discord.Net.Rpc/Commands/RpcCommandContext.cs
  46. +0
    -0
      experiment/Discord.Net.Rpc/Discord.Net.Rpc.csproj
  47. +0
    -0
      experiment/Discord.Net.Rpc/DiscordRpcApiClient.cs
  48. +0
    -0
      experiment/Discord.Net.Rpc/DiscordRpcClient.Events.cs
  49. +0
    -0
      experiment/Discord.Net.Rpc/DiscordRpcClient.cs
  50. +0
    -0
      experiment/Discord.Net.Rpc/DiscordRpcConfig.cs
  51. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/IRpcAudioChannel.cs
  52. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/IRpcMessageChannel.cs
  53. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/IRpcPrivateChannel.cs
  54. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/RpcChannel.cs
  55. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/RpcChannelSummary.cs
  56. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs
  57. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs
  58. +8
    -1
      experiment/Discord.Net.Rpc/Entities/Channels/RpcGuildChannel.cs
  59. +15
    -1
      experiment/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs
  60. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Channels/RpcVoiceChannel.cs
  61. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuild.cs
  62. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuildStatus.cs
  63. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuildSummary.cs
  64. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Messages/RpcMessage.cs
  65. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Messages/RpcSystemMessage.cs
  66. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Messages/RpcUserMessage.cs
  67. +0
    -0
      experiment/Discord.Net.Rpc/Entities/RpcEntity.cs
  68. +0
    -0
      experiment/Discord.Net.Rpc/Entities/UserVoiceProperties.cs
  69. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Users/Pan.cs
  70. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Users/RpcGuildUser.cs
  71. +1
    -1
      experiment/Discord.Net.Rpc/Entities/Users/RpcUser.cs
  72. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Users/RpcVoiceState.cs
  73. +0
    -0
      experiment/Discord.Net.Rpc/Entities/Users/RpcWebhookUser.cs
  74. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceDevice.cs
  75. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceDeviceProperties.cs
  76. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceModeProperties.cs
  77. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceProperties.cs
  78. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceSettings.cs
  79. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceShortcut.cs
  80. +0
    -0
      experiment/Discord.Net.Rpc/Entities/VoiceShortcutType.cs
  81. +0
    -0
      experiment/Discord.Net.Rpc/Extensions/EntityExtensions.cs
  82. +0
    -0
      experiment/Discord.Net.Rpc/RpcChannelEvent.cs
  83. +0
    -0
      experiment/Discord.Net.Rpc/RpcGlobalEvent.cs
  84. +0
    -0
      experiment/Discord.Net.Rpc/RpcGuildEvent.cs
  85. +2
    -4
      src/Discord.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs
  86. +2
    -4
      src/Discord.Net.Commands/Attributes/Preconditions/RequireUserPermissionAttribute.cs
  87. +7
    -2
      src/Discord.Net.Commands/CommandParser.cs
  88. +2
    -1
      src/Discord.Net.Commands/CommandService.cs
  89. +3
    -0
      src/Discord.Net.Commands/CommandServiceConfig.cs
  90. +7
    -2
      src/Discord.Net.Commands/Info/CommandInfo.cs
  91. +8
    -6
      src/Discord.Net.Commands/Readers/UserTypeReader.cs
  92. +8
    -2
      src/Discord.Net.Core/CDN.cs
  93. +19
    -0
      src/Discord.Net.Core/Entities/Activities/Game.cs
  94. +15
    -0
      src/Discord.Net.Core/Entities/Activities/GameAsset.cs
  95. +11
    -0
      src/Discord.Net.Core/Entities/Activities/GameParty.cs
  96. +16
    -0
      src/Discord.Net.Core/Entities/Activities/GameSecrets.cs
  97. +16
    -0
      src/Discord.Net.Core/Entities/Activities/GameTimestamps.cs
  98. +13
    -0
      src/Discord.Net.Core/Entities/Activities/IActivity.cs
  99. +22
    -0
      src/Discord.Net.Core/Entities/Activities/RichGame.cs
  100. +21
    -0
      src/Discord.Net.Core/Entities/Activities/StreamingGame.cs

+ 44
- 0
CONTRIBUTING.md View File

@@ -0,0 +1,44 @@
# Contributing

Discord.Net is an open-source project, and we appreciate any and all
contributions made by our community. However, please conform to the
following guidelines when possible:

## Development Cycle

We prefer all changes to the library to be discussed beforehand,
either in a GitHub issue, or in a discussion in our Discord channel
with library regulars or other contributors.

Issues that are tagged as "up for grabs" are free to be picked up by
any member of the community.

### Pull Requests

We prefer pull-requests that are descriptive of the changes being made
and highlight any potential benefits/drawbacks of the change, but these
types of write-ups are not required. See this [merge request](https://github.com/RogueException/Discord.Net/pull/793)
for an example of a well-written description.

## Semantic Versioning

This project follows [Semantic Versioning](http://semver.org/). When
writing changes to this project, it is recommended to write changes
that are SemVer compliant with the latest version of the library in
development.

The working release should be the latest build off of the `dev` branch,
but can also be found on the [development board](https://github.com/RogueException/Discord.Net/projects/1).

We follow the .NET Foundation's [Breaking Change Rules](https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/breaking-change-rules.md)
when determining the SemVer compliance of a change.

Obsoleting a method is considered a **minor** increment.

## Coding Style

We attempt to conform to the .NET Foundation's [Coding Style](https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md)
where possible.

As a general rule, follow the coding style already set in the file you
are editing, or look at a similar file if you are adding a new one.

+ 1
- 16
Discord.Net.sln View File

@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26730.12
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Core", "src\Discord.Net.Core\Discord.Net.Core.csproj", "{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Core", "src\Discord.Net.Core\Discord.Net.Core.csproj", "{91E9E7BD-75C9-4E98-84AA-2C271922E5C2}"
EndProject EndProject
@@ -8,8 +8,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Impls", "Impls", "{288C363D
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Rest", "src\Discord.Net.Rest\Discord.Net.Rest.csproj", "{BFC6DC28-0351-4573-926A-D4124244C04F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Rest", "src\Discord.Net.Rest\Discord.Net.Rest.csproj", "{BFC6DC28-0351-4573-926A-D4124244C04F}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Rpc", "src\Discord.Net.Rpc\Discord.Net.Rpc.csproj", "{5688A353-121E-40A1-8BFA-B17B91FB48FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Commands", "src\Discord.Net.Commands\Discord.Net.Commands.csproj", "{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Commands", "src\Discord.Net.Commands\Discord.Net.Commands.csproj", "{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.WebSocket", "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj", "{688FD1D8-7F01-4539-B2E9-F473C5D699C7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.WebSocket", "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj", "{688FD1D8-7F01-4539-B2E9-F473C5D699C7}"
@@ -58,18 +56,6 @@ Global
{BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x64.Build.0 = Debug|Any CPU {BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x64.Build.0 = Debug|Any CPU
{BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x86.ActiveCfg = Debug|Any CPU {BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x86.ActiveCfg = Debug|Any CPU
{BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x86.Build.0 = Debug|Any CPU {BFC6DC28-0351-4573-926A-D4124244C04F}.Release|x86.Build.0 = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|x64.ActiveCfg = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|x64.Build.0 = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|x86.ActiveCfg = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Debug|x86.Build.0 = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|Any CPU.Build.0 = Release|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|x64.ActiveCfg = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|x64.Build.0 = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|x86.ActiveCfg = Debug|Any CPU
{5688A353-121E-40A1-8BFA-B17B91FB48FB}.Release|x86.Build.0 = Debug|Any CPU
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|x64.ActiveCfg = Debug|Any CPU {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -136,7 +122,6 @@ Global
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{BFC6DC28-0351-4573-926A-D4124244C04F} = {288C363D-A636-4EAE-9AC1-4698B641B26E} {BFC6DC28-0351-4573-926A-D4124244C04F} = {288C363D-A636-4EAE-9AC1-4698B641B26E}
{5688A353-121E-40A1-8BFA-B17B91FB48FB} = {288C363D-A636-4EAE-9AC1-4698B641B26E}
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C} = {CC3D4B1C-9DE0-448B-8AE7-F3F1F3EC5C3A} {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C} = {CC3D4B1C-9DE0-448B-8AE7-F3F1F3EC5C3A}
{688FD1D8-7F01-4539-B2E9-F473C5D699C7} = {288C363D-A636-4EAE-9AC1-4698B641B26E} {688FD1D8-7F01-4539-B2E9-F473C5D699C7} = {288C363D-A636-4EAE-9AC1-4698B641B26E}
{6BDEEC08-417B-459F-9CA3-FF8BAB18CAC7} = {B0657AAE-DCC5-4FBF-8E5D-1FB578CF3012} {6BDEEC08-417B-459F-9CA3-FF8BAB18CAC7} = {B0657AAE-DCC5-4FBF-8E5D-1FB578CF3012}


+ 2
- 2
Discord.Net.targets View File

@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<VersionPrefix>2.0.0-alpha</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>beta</VersionSuffix>
<Authors>RogueException</Authors> <Authors>RogueException</Authors>
<PackageTags>discord;discordapp</PackageTags> <PackageTags>discord;discordapp</PackageTags>
<PackageProjectUrl>https://github.com/RogueException/Discord.Net</PackageProjectUrl> <PackageProjectUrl>https://github.com/RogueException/Discord.Net</PackageProjectUrl>


+ 2
- 2
README.md View File

@@ -2,11 +2,11 @@
[![NuGet](https://img.shields.io/nuget/vpre/Discord.Net.svg?maxAge=2592000?style=plastic)](https://www.nuget.org/packages/Discord.Net) [![NuGet](https://img.shields.io/nuget/vpre/Discord.Net.svg?maxAge=2592000?style=plastic)](https://www.nuget.org/packages/Discord.Net)
[![MyGet](https://img.shields.io/myget/discord-net/vpre/Discord.Net.svg)](https://www.myget.org/feed/Packages/discord-net) [![MyGet](https://img.shields.io/myget/discord-net/vpre/Discord.Net.svg)](https://www.myget.org/feed/Packages/discord-net)
[![Build status](https://ci.appveyor.com/api/projects/status/5sb7n8a09w9clute/branch/dev?svg=true)](https://ci.appveyor.com/project/RogueException/discord-net/branch/dev) [![Build status](https://ci.appveyor.com/api/projects/status/5sb7n8a09w9clute/branch/dev?svg=true)](https://ci.appveyor.com/project/RogueException/discord-net/branch/dev)
[![Discord](https://discordapp.com/api/guilds/81384788765712384/widget.png)](https://discord.gg/0SBTUU1wZTVjAMPx)
[![Discord](https://discordapp.com/api/guilds/81384788765712384/widget.png)](https://discord.gg/jkrBmQR)


An unofficial .NET API Wrapper for the Discord client (http://discordapp.com). An unofficial .NET API Wrapper for the Discord client (http://discordapp.com).


Check out the [documentation](https://discord.foxbot.me/docs/) or join the [Discord API Chat](https://discord.gg/0SBTUU1wZTVjAMPx).
Check out the [documentation](https://discord.foxbot.me/docs/) or join the [Discord API Chat](https://discord.gg/jkrBmQR).


## Installation ## Installation
### Stable (NuGet) ### Stable (NuGet)


+ 1
- 2
appveyor.yml View File

@@ -26,7 +26,6 @@ after_build:
- ps: dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.Rpc\Discord.Net.Rpc.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
- ps: dotnet pack "src\Discord.Net.Providers.WS4Net\Discord.Net.Providers.WS4Net.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG" - ps: dotnet pack "src\Discord.Net.Providers.WS4Net\Discord.Net.Providers.WS4Net.csproj" -c "Release" -o "../../artifacts" --no-build /p:BuildNumber="$Env:BUILD" /p:IsTagBuild="$Env:APPVEYOR_REPO_TAG"
@@ -34,7 +33,7 @@ after_build:
if ($Env:APPVEYOR_REPO_TAG -eq "true") { if ($Env:APPVEYOR_REPO_TAG -eq "true") {
nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="" nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix=""
} else { } else {
nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="-build-$Env:BUILD"
nuget pack src\Discord.Net\Discord.Net.nuspec -OutputDirectory "artifacts" -properties suffix="-$Env:BUILD"
} }
- ps: Get-ChildItem artifacts\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - ps: Get-ChildItem artifacts\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }




+ 3
- 3
docs/guides/commands/commands.md View File

@@ -93,9 +93,9 @@ If you would like a parameter to parse until the end of a Command,
flag the parameter with the [RemainderAttribute]. This will allow a flag the parameter with the [RemainderAttribute]. This will allow a
user to invoke a Command without wrapping a parameter in quotes. user to invoke a Command without wrapping a parameter in quotes.


Finally, flag your Command with the [CommandAttribute] (you must
Finally, flag your Command with the [CommandAttribute]. (you must
specify a name for this Command, except for when it is part of a specify a name for this Command, except for when it is part of a
Module Group - see below).
Module Group - see below)


[RemainderAttribute]: xref:Discord.Commands.RemainderAttribute [RemainderAttribute]: xref:Discord.Commands.RemainderAttribute
[CommandAttribute]: xref:Discord.Commands.CommandAttribute [CommandAttribute]: xref:Discord.Commands.CommandAttribute
@@ -340,4 +340,4 @@ and must be explicitly added.


To install a TypeReader, invoke [CommandService.AddTypeReader]. To install a TypeReader, invoke [CommandService.AddTypeReader].


[CommandService.AddTypeReader]: xref:Discord.Commands.CommandService#Discord_Commands_CommandService_AddTypeReader__1_Discord_Commands_TypeReader_
[CommandService.AddTypeReader]: xref:Discord.Commands.CommandService#Discord_Commands_CommandService_AddTypeReader__1_Discord_Commands_TypeReader_

src/Discord.Net.Rpc/API/Rpc/AuthenticateParams.cs → experiment/Discord.Net.Rpc/API/Rpc/AuthenticateParams.cs View File


src/Discord.Net.Rpc/API/Rpc/AuthenticateResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/AuthenticateResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/AuthorizeParams.cs → experiment/Discord.Net.Rpc/API/Rpc/AuthorizeParams.cs View File


src/Discord.Net.Rpc/API/Rpc/AuthorizeResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/AuthorizeResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/Channel.cs → experiment/Discord.Net.Rpc/API/Rpc/Channel.cs View File


src/Discord.Net.Rpc/API/Rpc/ChannelSubscriptionParams.cs → experiment/Discord.Net.Rpc/API/Rpc/ChannelSubscriptionParams.cs View File


src/Discord.Net.Rpc/API/Rpc/ChannelSummary.cs → experiment/Discord.Net.Rpc/API/Rpc/ChannelSummary.cs View File


src/Discord.Net.Rpc/API/Rpc/ErrorEvent.cs → experiment/Discord.Net.Rpc/API/Rpc/ErrorEvent.cs View File


src/Discord.Net.Rpc/API/Rpc/ExtendedVoiceState.cs → experiment/Discord.Net.Rpc/API/Rpc/ExtendedVoiceState.cs View File


src/Discord.Net.Rpc/API/Rpc/GetChannelParams.cs → experiment/Discord.Net.Rpc/API/Rpc/GetChannelParams.cs View File


src/Discord.Net.Rpc/API/Rpc/GetChannelsParams.cs → experiment/Discord.Net.Rpc/API/Rpc/GetChannelsParams.cs View File


src/Discord.Net.Rpc/API/Rpc/GetChannelsResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/GetChannelsResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/GetGuildParams.cs → experiment/Discord.Net.Rpc/API/Rpc/GetGuildParams.cs View File


src/Discord.Net.Rpc/API/Rpc/GetGuildsParams.cs → experiment/Discord.Net.Rpc/API/Rpc/GetGuildsParams.cs View File


src/Discord.Net.Rpc/API/Rpc/GetGuildsResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/GetGuildsResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/Guild.cs → experiment/Discord.Net.Rpc/API/Rpc/Guild.cs View File


src/Discord.Net.Rpc/API/Rpc/GuildMember.cs → experiment/Discord.Net.Rpc/API/Rpc/GuildMember.cs View File


src/Discord.Net.Rpc/API/Rpc/GuildStatusEvent.cs → experiment/Discord.Net.Rpc/API/Rpc/GuildStatusEvent.cs View File


src/Discord.Net.Rpc/API/Rpc/GuildSubscriptionParams.cs → experiment/Discord.Net.Rpc/API/Rpc/GuildSubscriptionParams.cs View File


src/Discord.Net.Rpc/API/Rpc/GuildSummary.cs → experiment/Discord.Net.Rpc/API/Rpc/GuildSummary.cs View File


src/Discord.Net.Rpc/API/Rpc/Message.cs → experiment/Discord.Net.Rpc/API/Rpc/Message.cs View File


src/Discord.Net.Rpc/API/Rpc/MessageEvent.cs → experiment/Discord.Net.Rpc/API/Rpc/MessageEvent.cs View File


src/Discord.Net.Rpc/API/Rpc/Pan.cs → experiment/Discord.Net.Rpc/API/Rpc/Pan.cs View File


src/Discord.Net.Rpc/API/Rpc/ReadyEvent.cs → experiment/Discord.Net.Rpc/API/Rpc/ReadyEvent.cs View File


src/Discord.Net.Rpc/API/Rpc/RpcConfig.cs → experiment/Discord.Net.Rpc/API/Rpc/RpcConfig.cs View File


src/Discord.Net.Rpc/API/Rpc/SelectChannelParams.cs → experiment/Discord.Net.Rpc/API/Rpc/SelectChannelParams.cs View File


src/Discord.Net.Rpc/API/Rpc/SetLocalVolumeParams.cs → experiment/Discord.Net.Rpc/API/Rpc/SetLocalVolumeParams.cs View File


src/Discord.Net.Rpc/API/Rpc/SetLocalVolumeResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/SetLocalVolumeResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/SpeakingEvent.cs → experiment/Discord.Net.Rpc/API/Rpc/SpeakingEvent.cs View File


src/Discord.Net.Rpc/API/Rpc/SubscriptionResponse.cs → experiment/Discord.Net.Rpc/API/Rpc/SubscriptionResponse.cs View File


src/Discord.Net.Rpc/API/Rpc/UserVoiceSettings.cs → experiment/Discord.Net.Rpc/API/Rpc/UserVoiceSettings.cs View File


src/Discord.Net.Rpc/API/Rpc/VoiceDevice.cs → experiment/Discord.Net.Rpc/API/Rpc/VoiceDevice.cs View File


src/Discord.Net.Rpc/API/Rpc/VoiceDeviceSettings.cs → experiment/Discord.Net.Rpc/API/Rpc/VoiceDeviceSettings.cs View File


src/Discord.Net.Rpc/API/Rpc/VoiceMode.cs → experiment/Discord.Net.Rpc/API/Rpc/VoiceMode.cs View File


src/Discord.Net.Rpc/API/Rpc/VoiceSettings.cs → experiment/Discord.Net.Rpc/API/Rpc/VoiceSettings.cs View File


src/Discord.Net.Rpc/API/Rpc/VoiceShortcut.cs → experiment/Discord.Net.Rpc/API/Rpc/VoiceShortcut.cs View File


src/Discord.Net.Rpc/API/RpcFrame.cs → experiment/Discord.Net.Rpc/API/RpcFrame.cs View File


src/Discord.Net.Rpc/AssemblyInfo.cs → experiment/Discord.Net.Rpc/AssemblyInfo.cs View File


src/Discord.Net.Rpc/Commands/RpcCommandContext.cs → experiment/Discord.Net.Rpc/Commands/RpcCommandContext.cs View File


src/Discord.Net.Rpc/Discord.Net.Rpc.csproj → experiment/Discord.Net.Rpc/Discord.Net.Rpc.csproj View File


src/Discord.Net.Rpc/DiscordRpcApiClient.cs → experiment/Discord.Net.Rpc/DiscordRpcApiClient.cs View File


src/Discord.Net.Rpc/DiscordRpcClient.Events.cs → experiment/Discord.Net.Rpc/DiscordRpcClient.Events.cs View File


src/Discord.Net.Rpc/DiscordRpcClient.cs → experiment/Discord.Net.Rpc/DiscordRpcClient.cs View File


src/Discord.Net.Rpc/DiscordRpcConfig.cs → experiment/Discord.Net.Rpc/DiscordRpcConfig.cs View File


src/Discord.Net.Rpc/Entities/Channels/IRpcAudioChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/IRpcAudioChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/IRpcMessageChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/IRpcMessageChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/IRpcPrivateChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/IRpcPrivateChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/RpcChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/RpcChannelSummary.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcChannelSummary.cs View File


src/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs View File


src/Discord.Net.Rpc/Entities/Channels/RpcGuildChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcGuildChannel.cs View File

@@ -10,6 +10,7 @@ namespace Discord.Rpc
{ {
public ulong GuildId { get; } public ulong GuildId { get; }
public int Position { get; private set; } public int Position { get; private set; }
public ulong? CategoryId { get; private set; }


internal RpcGuildChannel(DiscordRpcClient discord, ulong id, ulong guildId) internal RpcGuildChannel(DiscordRpcClient discord, ulong id, ulong guildId)
: base(discord, id) : base(discord, id)
@@ -51,12 +52,18 @@ namespace Discord.Rpc


public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
=> await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false); => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false);


public override string ToString() => Name; public override string ToString() => Name;


//IGuildChannel //IGuildChannel
public Task<ICategoryChannel> GetCategoryAsync()
{
//Always fails
throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object.");
}

IGuild IGuildChannel.Guild IGuild IGuildChannel.Guild
{ {
get get

src/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs View File

@@ -68,11 +68,25 @@ namespace Discord.Rpc
=> ChannelHelper.TriggerTypingAsync(this, Discord, options); => ChannelHelper.TriggerTypingAsync(this, Discord, options);
public IDisposable EnterTypingState(RequestOptions options = null) public IDisposable EnterTypingState(RequestOptions options = null)
=> ChannelHelper.EnterTypingState(this, Discord, options); => ChannelHelper.EnterTypingState(this, Discord, options);

//Webhooks
public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
=> ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options);
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetWebhookAsync(this, Discord, id, options);
public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
=> ChannelHelper.GetWebhooksAsync(this, Discord, options);

private string DebuggerDisplay => $"{Name} ({Id}, Text)"; private string DebuggerDisplay => $"{Name} ({Id}, Text)";
//ITextChannel //ITextChannel
string ITextChannel.Topic { get { throw new NotSupportedException(); } } string ITextChannel.Topic { get { throw new NotSupportedException(); } }
async Task<IWebhook> ITextChannel.CreateWebhookAsync(string name, Stream avatar, RequestOptions options)
=> await CreateWebhookAsync(name, avatar, options);
async Task<IWebhook> ITextChannel.GetWebhookAsync(ulong id, RequestOptions options)
=> await GetWebhookAsync(id, options);
async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options)
=> await GetWebhooksAsync(options);


//IMessageChannel //IMessageChannel
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)

src/Discord.Net.Rpc/Entities/Channels/RpcVoiceChannel.cs → experiment/Discord.Net.Rpc/Entities/Channels/RpcVoiceChannel.cs View File


src/Discord.Net.Rpc/Entities/Guilds/RpcGuild.cs → experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuild.cs View File


src/Discord.Net.Rpc/Entities/Guilds/RpcGuildStatus.cs → experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuildStatus.cs View File


src/Discord.Net.Rpc/Entities/Guilds/RpcGuildSummary.cs → experiment/Discord.Net.Rpc/Entities/Guilds/RpcGuildSummary.cs View File


src/Discord.Net.Rpc/Entities/Messages/RpcMessage.cs → experiment/Discord.Net.Rpc/Entities/Messages/RpcMessage.cs View File


src/Discord.Net.Rpc/Entities/Messages/RpcSystemMessage.cs → experiment/Discord.Net.Rpc/Entities/Messages/RpcSystemMessage.cs View File


src/Discord.Net.Rpc/Entities/Messages/RpcUserMessage.cs → experiment/Discord.Net.Rpc/Entities/Messages/RpcUserMessage.cs View File


src/Discord.Net.Rpc/Entities/RpcEntity.cs → experiment/Discord.Net.Rpc/Entities/RpcEntity.cs View File


src/Discord.Net.Rpc/Entities/UserVoiceProperties.cs → experiment/Discord.Net.Rpc/Entities/UserVoiceProperties.cs View File


src/Discord.Net.Rpc/Entities/Users/Pan.cs → experiment/Discord.Net.Rpc/Entities/Users/Pan.cs View File


src/Discord.Net.Rpc/Entities/Users/RpcGuildUser.cs → experiment/Discord.Net.Rpc/Entities/Users/RpcGuildUser.cs View File


src/Discord.Net.Rpc/Entities/Users/RpcUser.cs → experiment/Discord.Net.Rpc/Entities/Users/RpcUser.cs View File

@@ -18,7 +18,7 @@ namespace Discord.Rpc
public string Discriminator => DiscriminatorValue.ToString("D4"); public string Discriminator => DiscriminatorValue.ToString("D4");
public string Mention => MentionUtils.MentionUser(Id); public string Mention => MentionUtils.MentionUser(Id);
public virtual bool IsWebhook => false; public virtual bool IsWebhook => false;
public virtual Game? Game => null;
public virtual IActivity Activity => null;
public virtual UserStatus Status => UserStatus.Offline; public virtual UserStatus Status => UserStatus.Offline;


internal RpcUser(DiscordRpcClient discord, ulong id) internal RpcUser(DiscordRpcClient discord, ulong id)

src/Discord.Net.Rpc/Entities/Users/RpcVoiceState.cs → experiment/Discord.Net.Rpc/Entities/Users/RpcVoiceState.cs View File


src/Discord.Net.Rpc/Entities/Users/RpcWebhookUser.cs → experiment/Discord.Net.Rpc/Entities/Users/RpcWebhookUser.cs View File


src/Discord.Net.Rpc/Entities/VoiceDevice.cs → experiment/Discord.Net.Rpc/Entities/VoiceDevice.cs View File


src/Discord.Net.Rpc/Entities/VoiceDeviceProperties.cs → experiment/Discord.Net.Rpc/Entities/VoiceDeviceProperties.cs View File


src/Discord.Net.Rpc/Entities/VoiceModeProperties.cs → experiment/Discord.Net.Rpc/Entities/VoiceModeProperties.cs View File


src/Discord.Net.Rpc/Entities/VoiceProperties.cs → experiment/Discord.Net.Rpc/Entities/VoiceProperties.cs View File


src/Discord.Net.Rpc/Entities/VoiceSettings.cs → experiment/Discord.Net.Rpc/Entities/VoiceSettings.cs View File


src/Discord.Net.Rpc/Entities/VoiceShortcut.cs → experiment/Discord.Net.Rpc/Entities/VoiceShortcut.cs View File


src/Discord.Net.Rpc/Entities/VoiceShortcutType.cs → experiment/Discord.Net.Rpc/Entities/VoiceShortcutType.cs View File


src/Discord.Net.Rpc/Extensions/EntityExtensions.cs → experiment/Discord.Net.Rpc/Extensions/EntityExtensions.cs View File


src/Discord.Net.Rpc/RpcChannelEvent.cs → experiment/Discord.Net.Rpc/RpcChannelEvent.cs View File


src/Discord.Net.Rpc/RpcGlobalEvent.cs → experiment/Discord.Net.Rpc/RpcGlobalEvent.cs View File


src/Discord.Net.Rpc/RpcGuildEvent.cs → experiment/Discord.Net.Rpc/RpcGuildEvent.cs View File


+ 2
- 4
src/Discord.Net.Commands/Attributes/Preconditions/RequireBotPermissionAttribute.cs View File

@@ -57,13 +57,11 @@ namespace Discord.Commands


if (ChannelPermission.HasValue) if (ChannelPermission.HasValue)
{ {
var guildChannel = context.Channel as IGuildChannel;

ChannelPermissions perms; ChannelPermissions perms;
if (guildChannel != null)
if (context.Channel is IGuildChannel guildChannel)
perms = guildUser.GetPermissions(guildChannel); perms = guildUser.GetPermissions(guildChannel);
else else
perms = ChannelPermissions.All(guildChannel);
perms = ChannelPermissions.All(context.Channel);


if (!perms.Has(ChannelPermission.Value)) if (!perms.Has(ChannelPermission.Value))
return PreconditionResult.FromError($"Bot requires channel permission {ChannelPermission.Value}"); return PreconditionResult.FromError($"Bot requires channel permission {ChannelPermission.Value}");


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

@@ -56,13 +56,11 @@ namespace Discord.Commands


if (ChannelPermission.HasValue) if (ChannelPermission.HasValue)
{ {
var guildChannel = context.Channel as IGuildChannel;

ChannelPermissions perms; ChannelPermissions perms;
if (guildChannel != null)
if (context.Channel is IGuildChannel guildChannel)
perms = guildUser.GetPermissions(guildChannel); perms = guildUser.GetPermissions(guildChannel);
else else
perms = ChannelPermissions.All(guildChannel);
perms = ChannelPermissions.All(context.Channel);


if (!perms.Has(ChannelPermission.Value)) if (!perms.Has(ChannelPermission.Value))
return Task.FromResult(PreconditionResult.FromError($"User requires channel permission {ChannelPermission.Value}")); return Task.FromResult(PreconditionResult.FromError($"User requires channel permission {ChannelPermission.Value}"));


+ 7
- 2
src/Discord.Net.Commands/CommandParser.cs View File

@@ -14,7 +14,7 @@ namespace Discord.Commands
QuotedParameter QuotedParameter
} }
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, IServiceProvider services, string input, int startPos)
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos)
{ {
ParameterInfo curParam = null; ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length); StringBuilder argBuilder = new StringBuilder(input.Length);
@@ -109,7 +109,12 @@ namespace Discord.Commands
if (argString != null) if (argString != null)
{ {
if (curParam == null) if (curParam == null)
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
{
if (ignoreExtraArgs)
break;
else
return ParseResult.FromError(CommandError.BadArgCount, "The input text has too many parameters.");
}


var typeReaderResult = await curParam.ParseAsync(context, argString, services).ConfigureAwait(false); var typeReaderResult = await curParam.ParseAsync(context, argString, services).ConfigureAwait(false);
if (!typeReaderResult.IsSuccess && typeReaderResult.Error != CommandError.MultipleMatches) if (!typeReaderResult.IsSuccess && typeReaderResult.Error != CommandError.MultipleMatches)


+ 2
- 1
src/Discord.Net.Commands/CommandService.cs View File

@@ -27,7 +27,7 @@ namespace Discord.Commands
private readonly HashSet<ModuleInfo> _moduleDefs; private readonly HashSet<ModuleInfo> _moduleDefs;
private readonly CommandMap _map; private readonly CommandMap _map;


internal readonly bool _caseSensitive, _throwOnError;
internal readonly bool _caseSensitive, _throwOnError, _ignoreExtraArgs;
internal readonly char _separatorChar; internal readonly char _separatorChar;
internal readonly RunMode _defaultRunMode; internal readonly RunMode _defaultRunMode;
internal readonly Logger _cmdLogger; internal readonly Logger _cmdLogger;
@@ -42,6 +42,7 @@ namespace Discord.Commands
{ {
_caseSensitive = config.CaseSensitiveCommands; _caseSensitive = config.CaseSensitiveCommands;
_throwOnError = config.ThrowOnError; _throwOnError = config.ThrowOnError;
_ignoreExtraArgs = config.IgnoreExtraArgs;
_separatorChar = config.SeparatorChar; _separatorChar = config.SeparatorChar;
_defaultRunMode = config.DefaultRunMode; _defaultRunMode = config.DefaultRunMode;
if (_defaultRunMode == RunMode.Default) if (_defaultRunMode == RunMode.Default)


+ 3
- 0
src/Discord.Net.Commands/CommandServiceConfig.cs View File

@@ -15,5 +15,8 @@


/// <summary> Determines whether RunMode.Sync commands should push exceptions up to the caller. </summary> /// <summary> Determines whether RunMode.Sync commands should push exceptions up to the caller. </summary>
public bool ThrowOnError { get; set; } = true; public bool ThrowOnError { get; set; } = true;

/// <summary> Determines whether extra parameters should be ignored. </summary>
public bool IgnoreExtraArgs { get; set; } = false;
} }
} }

+ 7
- 2
src/Discord.Net.Commands/Info/CommandInfo.cs View File

@@ -18,6 +18,7 @@ namespace Discord.Commands
private static readonly System.Reflection.MethodInfo _convertParamsMethod = typeof(CommandInfo).GetTypeInfo().GetDeclaredMethod(nameof(ConvertParamsList)); private static readonly System.Reflection.MethodInfo _convertParamsMethod = typeof(CommandInfo).GetTypeInfo().GetDeclaredMethod(nameof(ConvertParamsList));
private static readonly ConcurrentDictionary<Type, Func<IEnumerable<object>, object>> _arrayConverters = new ConcurrentDictionary<Type, Func<IEnumerable<object>, object>>(); private static readonly ConcurrentDictionary<Type, Func<IEnumerable<object>, object>> _arrayConverters = new ConcurrentDictionary<Type, Func<IEnumerable<object>, object>>();


private readonly CommandService _commandService;
private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action; private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action;


public ModuleInfo Module { get; } public ModuleInfo Module { get; }
@@ -64,6 +65,7 @@ namespace Discord.Commands
HasVarArgs = builder.Parameters.Count > 0 ? builder.Parameters[builder.Parameters.Count - 1].IsMultiple : false; HasVarArgs = builder.Parameters.Count > 0 ? builder.Parameters[builder.Parameters.Count - 1].IsMultiple : false;


_action = builder.Callback; _action = builder.Callback;
_commandService = service;
} }


public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, IServiceProvider services = null) public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, IServiceProvider services = null)
@@ -117,7 +119,7 @@ namespace Discord.Commands
return ParseResult.FromError(preconditionResult); return ParseResult.FromError(preconditionResult);


string input = searchResult.Text.Substring(startIndex); string input = searchResult.Text.Substring(startIndex);
return await CommandParser.ParseArgsAsync(this, context, services, input, 0).ConfigureAwait(false);
return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0).ConfigureAwait(false);
} }


public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)
@@ -199,10 +201,13 @@ namespace Discord.Commands
return result; return result;
} }
else else
{
await task.ConfigureAwait(false); await task.ConfigureAwait(false);
var result = ExecuteResult.FromSuccess();
await Module.Service._commandExecutedEvent.InvokeAsync(this, context, result).ConfigureAwait(false);
}


var executeResult = ExecuteResult.FromSuccess(); var executeResult = ExecuteResult.FromSuccess();
await Module.Service._commandExecutedEvent.InvokeAsync(this, context, executeResult).ConfigureAwait(false);
return executeResult; return executeResult;
} }
catch (Exception ex) catch (Exception ex)


+ 8
- 6
src/Discord.Net.Commands/Readers/UserTypeReader.cs View File

@@ -13,7 +13,7 @@ namespace Discord.Commands
public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
{ {
var results = new Dictionary<ulong, TypeReaderValue>(); var results = new Dictionary<ulong, TypeReaderValue>();
IReadOnlyCollection<IUser> channelUsers = (await context.Channel.GetUsersAsync(CacheMode.CacheOnly).Flatten().ConfigureAwait(false)).ToArray(); //TODO: must be a better way?
IAsyncEnumerable<IUser> channelUsers = context.Channel.GetUsersAsync(CacheMode.CacheOnly).Flatten(); // it's better
IReadOnlyCollection<IGuildUser> guildUsers = ImmutableArray.Create<IGuildUser>(); IReadOnlyCollection<IGuildUser> guildUsers = ImmutableArray.Create<IGuildUser>();
ulong id; ulong id;


@@ -45,7 +45,7 @@ namespace Discord.Commands
string username = input.Substring(0, index); string username = input.Substring(0, index);
if (ushort.TryParse(input.Substring(index + 1), out ushort discriminator)) if (ushort.TryParse(input.Substring(index + 1), out ushort discriminator))
{ {
var channelUser = channelUsers.FirstOrDefault(x => x.DiscriminatorValue == discriminator &&
var channelUser = await channelUsers.FirstOrDefault(x => x.DiscriminatorValue == discriminator &&
string.Equals(username, x.Username, StringComparison.OrdinalIgnoreCase)); string.Equals(username, x.Username, StringComparison.OrdinalIgnoreCase));
AddResult(results, channelUser as T, channelUser?.Username == username ? 0.85f : 0.75f); AddResult(results, channelUser as T, channelUser?.Username == username ? 0.85f : 0.75f);


@@ -57,8 +57,9 @@ namespace Discord.Commands


//By Username (0.5-0.6) //By Username (0.5-0.6)
{ {
foreach (var channelUser in channelUsers.Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase)))
AddResult(results, channelUser as T, channelUser.Username == input ? 0.65f : 0.55f);
await channelUsers
.Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase))
.ForEachAsync(channelUser => AddResult(results, channelUser as T, channelUser.Username == input ? 0.65f : 0.55f));
foreach (var guildUser in guildUsers.Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase))) foreach (var guildUser in guildUsers.Where(x => string.Equals(input, x.Username, StringComparison.OrdinalIgnoreCase)))
AddResult(results, guildUser as T, guildUser.Username == input ? 0.60f : 0.50f); AddResult(results, guildUser as T, guildUser.Username == input ? 0.60f : 0.50f);
@@ -66,8 +67,9 @@ namespace Discord.Commands


//By Nickname (0.5-0.6) //By Nickname (0.5-0.6)
{ {
foreach (var channelUser in channelUsers.Where(x => string.Equals(input, (x as IGuildUser)?.Nickname, StringComparison.OrdinalIgnoreCase)))
AddResult(results, channelUser as T, (channelUser as IGuildUser).Nickname == input ? 0.65f : 0.55f);
await channelUsers
.Where(x => string.Equals(input, (x as IGuildUser)?.Nickname, StringComparison.OrdinalIgnoreCase))
.ForEachAsync(channelUser => AddResult(results, channelUser as T, (channelUser as IGuildUser).Nickname == input ? 0.65f : 0.55f));


foreach (var guildUser in guildUsers.Where(x => string.Equals(input, (x as IGuildUser).Nickname, StringComparison.OrdinalIgnoreCase))) foreach (var guildUser in guildUsers.Where(x => string.Equals(input, (x as IGuildUser).Nickname, StringComparison.OrdinalIgnoreCase)))
AddResult(results, guildUser as T, (guildUser as IGuildUser).Nickname == input ? 0.60f : 0.50f); AddResult(results, guildUser as T, (guildUser as IGuildUser).Nickname == input ? 0.60f : 0.50f);


+ 8
- 2
src/Discord.Net.Core/CDN.cs View File

@@ -19,8 +19,14 @@ namespace Discord
=> splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null; => splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null;
public static string GetChannelIconUrl(ulong channelId, string iconId) public static string GetChannelIconUrl(ulong channelId, string iconId)
=> iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null; => iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null;
public static string GetEmojiUrl(ulong emojiId)
=> $"{DiscordConfig.CDNUrl}emojis/{emojiId}.png";
public static string GetEmojiUrl(ulong emojiId, bool animated)
=> $"{DiscordConfig.CDNUrl}emojis/{emojiId}.{(animated ? "gif" : "png")}";

public static string GetRichAssetUrl(ulong appId, string assetId, ushort size, ImageFormat format)
{
string extension = FormatToExtension(format, "");
return $"{DiscordConfig.CDNUrl}app-assets/{appId}/{assetId}.{extension}?size={size}";
}


private static string FormatToExtension(ImageFormat format, string imageId) private static string FormatToExtension(ImageFormat format, string imageId)
{ {


+ 19
- 0
src/Discord.Net.Core/Entities/Activities/Game.cs View File

@@ -0,0 +1,19 @@
using System.Diagnostics;

namespace Discord
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class Game : IActivity
{
public string Name { get; internal set; }

internal Game() { }
public Game(string name)
{
Name = name;
}
public override string ToString() => Name;
private string DebuggerDisplay => Name;
}
}

+ 15
- 0
src/Discord.Net.Core/Entities/Activities/GameAsset.cs View File

@@ -0,0 +1,15 @@
namespace Discord
{
public class GameAsset
{
internal GameAsset() { }

internal ulong ApplicationId { get; set; }
public string Text { get; internal set; }
public string ImageId { get; internal set; }
public string GetImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
=> CDN.GetRichAssetUrl(ApplicationId, ImageId, size, format);
}
}

+ 11
- 0
src/Discord.Net.Core/Entities/Activities/GameParty.cs View File

@@ -0,0 +1,11 @@
namespace Discord
{
public class GameParty
{
internal GameParty() { }

public string Id { get; internal set; }
public int Members { get; internal set; }
public int Capacity { get; internal set; }
}
}

+ 16
- 0
src/Discord.Net.Core/Entities/Activities/GameSecrets.cs View File

@@ -0,0 +1,16 @@
namespace Discord
{
public class GameSecrets
{
public string Match { get; }
public string Join { get; }
public string Spectate { get; }

internal GameSecrets(string match, string join, string spectate)
{
Match = match;
Join = join;
Spectate = spectate;
}
}
}

+ 16
- 0
src/Discord.Net.Core/Entities/Activities/GameTimestamps.cs View File

@@ -0,0 +1,16 @@
using System;

namespace Discord
{
public class GameTimestamps
{
public DateTimeOffset? Start { get; }
public DateTimeOffset? End { get; }

internal GameTimestamps(DateTimeOffset? start, DateTimeOffset? end)
{
Start = start;
End = end;
}
}
}

+ 13
- 0
src/Discord.Net.Core/Entities/Activities/IActivity.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord
{
public interface IActivity
{
string Name { get; }
}
}

+ 22
- 0
src/Discord.Net.Core/Entities/Activities/RichGame.cs View File

@@ -0,0 +1,22 @@
using System.Diagnostics;

namespace Discord
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RichGame : Game
{
internal RichGame() { }

public string Details { get; internal set;}
public string State { get; internal set;}
public ulong ApplicationId { get; internal set; }
public GameAsset SmallAsset { get; internal set; }
public GameAsset LargeAsset { get; internal set; }
public GameParty Party { get; internal set; }
public GameSecrets Secrets { get; internal set; }
public GameTimestamps Timestamps { get; internal set; }
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} (Rich)";
}
}

+ 21
- 0
src/Discord.Net.Core/Entities/Activities/StreamingGame.cs View File

@@ -0,0 +1,21 @@
using System.Diagnostics;

namespace Discord
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class StreamingGame : Game
{
public string Url { get; internal set; }
public StreamType StreamType { get; internal set; }

public StreamingGame(string name, string url, StreamType streamType)
{
Name = name;
Url = url;
StreamType = streamType;
}
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Url})";
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save