@@ -14,25 +14,20 @@ trigger: | |||||
jobs: | jobs: | ||||
- job: Linux | - job: Linux | ||||
pool: | pool: | ||||
vmImage: 'ubuntu-16.04' | |||||
vmImage: 'ubuntu-latest' | |||||
steps: | steps: | ||||
- task: UseDotNet@2 | |||||
displayName: 'Use .NET Core sdk' | |||||
inputs: | |||||
packageType: 'sdk' | |||||
version: '3.x' | |||||
- template: azure/build.yml | - template: azure/build.yml | ||||
- job: Windows_build | - job: Windows_build | ||||
pool: | pool: | ||||
vmImage: 'windows-2019' | |||||
vmImage: 'windows-latest' | |||||
condition: ne(variables['Build.SourceBranch'], 'refs/heads/dev') | condition: ne(variables['Build.SourceBranch'], 'refs/heads/dev') | ||||
steps: | steps: | ||||
- template: azure/build.yml | - template: azure/build.yml | ||||
- job: Windows_deploy | - job: Windows_deploy | ||||
pool: | pool: | ||||
vmImage: 'windows-2019' | |||||
vmImage: 'windows-latest' | |||||
condition: | | condition: | | ||||
and ( | and ( | ||||
succeeded(), | succeeded(), | ||||
@@ -1,5 +1,10 @@ | |||||
steps: | 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 | displayName: Restore packages | ||||
- script: dotnet build "Discord.Net.sln" --no-restore -v minimal -c $(buildConfiguration) /p:BuildNumber=$(buildNumber) /p:IsTagBuild=$(buildTag) | - script: dotnet build "Discord.Net.sln" --no-restore -v minimal -c $(buildConfiguration) /p:BuildNumber=$(buildNumber) /p:IsTagBuild=$(buildTag) | ||||
@@ -2,7 +2,7 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -2,11 +2,11 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -2,12 +2,12 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||||
<RootNamespace>_03_sharded_client</RootNamespace> | <RootNamespace>_03_sharded_client</RootNamespace> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -10,6 +10,7 @@ namespace Discord | |||||
/// <summary> 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 </summary> | /// <summary> 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 </summary> | ||||
Guilds = 1 << 0, | Guilds = 1 << 0, | ||||
/// <summary> This intent includes GUILD_MEMBER_ADD, GUILD_MEMBER_UPDATE, GUILD_MEMBER_REMOVE </summary> | /// <summary> This intent includes GUILD_MEMBER_ADD, GUILD_MEMBER_UPDATE, GUILD_MEMBER_REMOVE </summary> | ||||
/// <remarks> This is a privileged intent and must be enabled in the Developer Portal. </remarks> | |||||
GuildMembers = 1 << 1, | GuildMembers = 1 << 1, | ||||
/// <summary> This intent includes GUILD_BAN_ADD, GUILD_BAN_REMOVE </summary> | /// <summary> This intent includes GUILD_BAN_ADD, GUILD_BAN_REMOVE </summary> | ||||
GuildBans = 1 << 2, | GuildBans = 1 << 2, | ||||
@@ -24,6 +25,7 @@ namespace Discord | |||||
/// <summary> This intent includes VOICE_STATE_UPDATE </summary> | /// <summary> This intent includes VOICE_STATE_UPDATE </summary> | ||||
GuildVoiceStates = 1 << 7, | GuildVoiceStates = 1 << 7, | ||||
/// <summary> This intent includes PRESENCE_UPDATE </summary> | /// <summary> This intent includes PRESENCE_UPDATE </summary> | ||||
/// <remarks> This is a privileged intent and must be enabled in the Developer Portal. </remarks> | |||||
GuildPresences = 1 << 8, | GuildPresences = 1 << 8, | ||||
/// <summary> This intent includes MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, MESSAGE_DELETE_BULK </summary> | /// <summary> This intent includes MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, MESSAGE_DELETE_BULK </summary> | ||||
GuildMessages = 1 << 9, | GuildMessages = 1 << 9, | ||||
@@ -80,17 +80,13 @@ namespace Discord.API | |||||
/// <exception cref="ArgumentException">Unknown OAuth token type.</exception> | /// <exception cref="ArgumentException">Unknown OAuth token type.</exception> | ||||
internal static string GetPrefixedToken(TokenType tokenType, string token) | 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) | internal virtual void Dispose(bool disposing) | ||||
{ | { | ||||
@@ -133,7 +129,7 @@ namespace Discord.API | |||||
RestClient.SetCancelToken(_loginCancelToken.Token); | RestClient.SetCancelToken(_loginCancelToken.Token); | ||||
AuthTokenType = tokenType; | AuthTokenType = tokenType; | ||||
AuthToken = token; | |||||
AuthToken = token?.TrimEnd(); | |||||
if (tokenType != TokenType.Webhook) | if (tokenType != TokenType.Webhook) | ||||
RestClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, AuthToken)); | RestClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, AuthToken)); | ||||
@@ -42,7 +42,8 @@ namespace Discord.Rest | |||||
base.Update(model); | base.Update(model); | ||||
CategoryId = model.CategoryId; | CategoryId = model.CategoryId; | ||||
Topic = model.Topic.Value; | Topic = model.Topic.Value; | ||||
SlowModeInterval = model.SlowMode.Value; | |||||
if (model.SlowMode.IsSpecified) | |||||
SlowModeInterval = model.SlowMode.Value; | |||||
IsNsfw = model.Nsfw.GetValueOrDefault(); | IsNsfw = model.Nsfw.GetValueOrDefault(); | ||||
} | } | ||||
@@ -141,7 +141,16 @@ namespace Discord | |||||
catch (OperationCanceledException) { } | 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); | await _logger.InfoAsync("Connected").ConfigureAwait(false); | ||||
State = ConnectionState.Connected; | State = ConnectionState.Connected; | ||||