diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 5a1d48082..2fe5abfe8 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -14,25 +14,20 @@ trigger:
jobs:
- job: Linux
pool:
- vmImage: 'ubuntu-16.04'
+ vmImage: 'ubuntu-latest'
steps:
- - task: UseDotNet@2
- displayName: 'Use .NET Core sdk'
- inputs:
- packageType: 'sdk'
- version: '3.x'
- template: azure/build.yml
- job: Windows_build
pool:
- vmImage: 'windows-2019'
+ vmImage: 'windows-latest'
condition: ne(variables['Build.SourceBranch'], 'refs/heads/dev')
steps:
- template: azure/build.yml
- job: Windows_deploy
pool:
- vmImage: 'windows-2019'
+ vmImage: 'windows-latest'
condition: |
and (
succeeded(),
diff --git a/azure/build.yml b/azure/build.yml
index 3399d7e3d..63ba93964 100644
--- a/azure/build.yml
+++ b/azure/build.yml
@@ -1,5 +1,10 @@
steps:
-- script: dotnet restore --no-cache Discord.Net.sln
+- task: DotNetCoreCLI@2
+ inputs:
+ command: 'restore'
+ projects: 'Discord.Net.sln'
+ feedsToUse: 'select'
+ verbosityRestore: 'Minimal'
displayName: Restore packages
- script: dotnet build "Discord.Net.sln" --no-restore -v minimal -c $(buildConfiguration) /p:BuildNumber=$(buildNumber) /p:IsTagBuild=$(buildTag)
diff --git a/samples/01_basic_ping_bot/01_basic_ping_bot.csproj b/samples/01_basic_ping_bot/01_basic_ping_bot.csproj
index 4b4e35e3f..128082edb 100644
--- a/samples/01_basic_ping_bot/01_basic_ping_bot.csproj
+++ b/samples/01_basic_ping_bot/01_basic_ping_bot.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp3.0
+ netcoreapp3.1
diff --git a/samples/02_commands_framework/02_commands_framework.csproj b/samples/02_commands_framework/02_commands_framework.csproj
index 84b30aa99..151e546a2 100644
--- a/samples/02_commands_framework/02_commands_framework.csproj
+++ b/samples/02_commands_framework/02_commands_framework.csproj
@@ -2,11 +2,11 @@
Exe
- netcoreapp3.0
+ netcoreapp3.1
-
+
diff --git a/samples/03_sharded_client/03_sharded_client.csproj b/samples/03_sharded_client/03_sharded_client.csproj
index a6599c117..24f9942f9 100644
--- a/samples/03_sharded_client/03_sharded_client.csproj
+++ b/samples/03_sharded_client/03_sharded_client.csproj
@@ -2,12 +2,12 @@
Exe
- netcoreapp3.0
+ netcoreapp3.1
_03_sharded_client
-
+
diff --git a/src/Discord.Net.Core/GatewayIntents.cs b/src/Discord.Net.Core/GatewayIntents.cs
index e58fc07d1..f3dc5ceb9 100644
--- a/src/Discord.Net.Core/GatewayIntents.cs
+++ b/src/Discord.Net.Core/GatewayIntents.cs
@@ -10,6 +10,7 @@ namespace Discord
/// This intent includes GUILD_CREATE, GUILD_UPDATE, GUILD_DELETE, GUILD_ROLE_CREATE, GUILD_ROLE_UPDATE, GUILD_ROLE_DELETE, CHANNEL_CREATE, CHANNEL_UPDATE, CHANNEL_DELETE, CHANNEL_PINS_UPDATE
Guilds = 1 << 0,
/// This intent includes GUILD_MEMBER_ADD, GUILD_MEMBER_UPDATE, GUILD_MEMBER_REMOVE
+ /// This is a privileged intent and must be enabled in the Developer Portal.
GuildMembers = 1 << 1,
/// This intent includes GUILD_BAN_ADD, GUILD_BAN_REMOVE
GuildBans = 1 << 2,
@@ -24,6 +25,7 @@ namespace Discord
/// This intent includes VOICE_STATE_UPDATE
GuildVoiceStates = 1 << 7,
/// This intent includes PRESENCE_UPDATE
+ /// This is a privileged intent and must be enabled in the Developer Portal.
GuildPresences = 1 << 8,
/// This intent includes MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, MESSAGE_DELETE_BULK
GuildMessages = 1 << 9,
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index 30984c0e9..c29f5e217 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -80,17 +80,13 @@ namespace Discord.API
/// Unknown OAuth token type.
internal static string GetPrefixedToken(TokenType tokenType, string token)
{
- switch (tokenType)
+ return tokenType switch
{
- case default(TokenType):
- return token;
- case TokenType.Bot:
- return $"Bot {token}";
- case TokenType.Bearer:
- return $"Bearer {token}";
- default:
- throw new ArgumentException(message: "Unknown OAuth token type.", paramName: nameof(tokenType));
- }
+ default(TokenType) => token,
+ TokenType.Bot => $"Bot {token}",
+ TokenType.Bearer => $"Bearer {token}",
+ _ => throw new ArgumentException(message: "Unknown OAuth token type.", paramName: nameof(tokenType)),
+ };
}
internal virtual void Dispose(bool disposing)
{
@@ -133,7 +129,7 @@ namespace Discord.API
RestClient.SetCancelToken(_loginCancelToken.Token);
AuthTokenType = tokenType;
- AuthToken = token;
+ AuthToken = token?.TrimEnd();
if (tokenType != TokenType.Webhook)
RestClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, AuthToken));
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
index c7ff7fa65..a85ef4f0b 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
@@ -42,7 +42,8 @@ namespace Discord.Rest
base.Update(model);
CategoryId = model.CategoryId;
Topic = model.Topic.Value;
- SlowModeInterval = model.SlowMode.Value;
+ if (model.SlowMode.IsSpecified)
+ SlowModeInterval = model.SlowMode.Value;
IsNsfw = model.Nsfw.GetValueOrDefault();
}
diff --git a/src/Discord.Net.WebSocket/ConnectionManager.cs b/src/Discord.Net.WebSocket/ConnectionManager.cs
index 8c9c743cb..e009674e7 100644
--- a/src/Discord.Net.WebSocket/ConnectionManager.cs
+++ b/src/Discord.Net.WebSocket/ConnectionManager.cs
@@ -141,7 +141,16 @@ namespace Discord
catch (OperationCanceledException) { }
});
- await _onConnecting().ConfigureAwait(false);
+ try
+ {
+ await _onConnecting().ConfigureAwait(false);
+ }
+ catch (TaskCanceledException ex)
+ {
+ Exception innerEx = ex.InnerException ?? new OperationCanceledException("Failed to connect.");
+ Error(innerEx);
+ throw innerEx;
+ }
await _logger.InfoAsync("Connected").ConfigureAwait(false);
State = ConnectionState.Connected;