Browse Source

Merge pull request #19 from discord-net/dev

update
pull/1595/head
Paulo GitHub 5 years ago
parent
commit
46e01974df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 27 deletions
  1. +3
    -8
      azure-pipelines.yml
  2. +6
    -1
      azure/build.yml
  3. +1
    -1
      samples/01_basic_ping_bot/01_basic_ping_bot.csproj
  4. +2
    -2
      samples/02_commands_framework/02_commands_framework.csproj
  5. +2
    -2
      samples/03_sharded_client/03_sharded_client.csproj
  6. +2
    -0
      src/Discord.Net.Core/GatewayIntents.cs
  7. +7
    -11
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  8. +2
    -1
      src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
  9. +10
    -1
      src/Discord.Net.WebSocket/ConnectionManager.cs

+ 3
- 8
azure-pipelines.yml View File

@@ -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(),


+ 6
- 1
azure/build.yml View File

@@ -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)


+ 1
- 1
samples/01_basic_ping_bot/01_basic_ping_bot.csproj View File

@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>


+ 2
- 2
samples/02_commands_framework/02_commands_framework.csproj View File

@@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
</ItemGroup>

<ItemGroup>


+ 2
- 2
samples/03_sharded_client/03_sharded_client.csproj View File

@@ -2,12 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_03_sharded_client</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
</ItemGroup>

<ItemGroup>


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

@@ -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>
Guilds = 1 << 0,
/// <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,
/// <summary> This intent includes GUILD_BAN_ADD, GUILD_BAN_REMOVE </summary>
GuildBans = 1 << 2,
@@ -24,6 +25,7 @@ namespace Discord
/// <summary> This intent includes VOICE_STATE_UPDATE </summary>
GuildVoiceStates = 1 << 7,
/// <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,
/// <summary> This intent includes MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, MESSAGE_DELETE_BULK </summary>
GuildMessages = 1 << 9,


+ 7
- 11
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -80,17 +80,13 @@ namespace Discord.API
/// <exception cref="ArgumentException">Unknown OAuth token type.</exception>
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));



+ 2
- 1
src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs View File

@@ -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();
}



+ 10
- 1
src/Discord.Net.WebSocket/ConnectionManager.cs View File

@@ -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;


Loading…
Cancel
Save