Browse Source

Fixed XML not being included in builds. Fixed Linq exception in SocketApplicationCommand.Update

pull/1923/head
quin lynch 4 years ago
parent
commit
ad75f6cb7d
9 changed files with 96 additions and 3 deletions
  1. +5
    -0
      src/Discord.Net.Commands/Discord.Net.Commands.csproj
  2. +5
    -0
      src/Discord.Net.Core/Discord.Net.Core.csproj
  3. +20
    -0
      src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataResolved.cs
  4. +5
    -0
      src/Discord.Net.Rest/Discord.Net.Rest.csproj
  5. +1
    -1
      src/Discord.Net.WebSocket/API/Gateway/ApplicationCommandCreatedUpdatedEvent.cs
  6. +5
    -0
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
  7. +2
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketApplicationCommand.cs
  8. +48
    -0
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandCache.cs
  9. +5
    -0
      src/Discord.Net.Webhook/Discord.Net.Webhook.csproj

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

@@ -25,5 +25,10 @@
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Discord.Net.Commands.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

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

@@ -32,4 +32,9 @@
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Discord.Net.Core.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

+ 20
- 0
src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataResolved.cs View File

@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Discord.API
{
internal class ApplicationCommandInteractionDataResolved
{
[JsonProperty("users")]
public Optional<Dictionary<ulong, User>> Users { get; set; }

[JsonProperty("members")]
public Optional<Dictionary<ulong, GuildMember>> Members { get; set; }

[JsonProperty("channels")]
public Optional<Dictionary<ulong, Channel>> Channels { get; set; }

[JsonProperty("roles")]
public Optional<Dictionary<ulong, Role>> Roles { get; set; }
}
}

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

@@ -30,4 +30,9 @@
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Discord.Net.Rest.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

+ 1
- 1
src/Discord.Net.WebSocket/API/Gateway/ApplicationCommandCreatedUpdatedEvent.cs View File

@@ -25,6 +25,6 @@ namespace Discord.API.Gateway
public ulong GuildId { get; set; }

[JsonProperty("options")]
public List<Discord.API.ApplicationCommandOption> Options { get; set; }
public Optional<List<Discord.API.ApplicationCommandOption>> Options { get; set; }
}
}

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

@@ -27,4 +27,9 @@
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Discord.Net.WebSocket.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

+ 2
- 2
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketApplicationCommand.cs View File

@@ -56,8 +56,8 @@ namespace Discord.WebSocket
this.Name = model.Name;
this.GuildId = model.GuildId;

this.Options = model.Options.Any()
? model.Options.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray()
this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray()
: new ImmutableArray<SocketApplicationCommandOption>();
}



+ 48
- 0
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandCache.cs View File

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

namespace Discord.WebSocket.Entities.Interaction
{
internal class SlashCommandCache
{
private readonly ConcurrentDictionary<ulong, SocketSlashCommand> _slashCommands;
private readonly ConcurrentQueue<ulong> _orderedSlashCommands;
private readonly int _size;

public IReadOnlyCollection<SocketSlashCommand> Messages => _slashCommands.ToReadOnlyCollection();

public SlashCommandCache(DiscordSocketClient client)
{
_size = 256;
_slashCommands = new ConcurrentDictionary<ulong, SocketSlashCommand>();

}

public void Add(SocketSlashCommand slashCommand)
{
if (_slashCommands.TryAdd(slashCommand.Id, slashCommand))
{
_orderedSlashCommands.Enqueue(slashCommand.Id);

while (_orderedSlashCommands.Count > _size && _orderedSlashCommands.TryDequeue(out ulong msgId))
_slashCommands.TryRemove(msgId, out _);
}
}

public SocketSlashCommand Remove(ulong id)
{
_slashCommands.TryRemove(id, out var slashCommand);
return slashCommand;
}

public SocketSlashCommand Get(ulong id)
{
_slashCommands.TryGetValue(id, out var slashCommands);
return slashCommands;
}
}
}

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

@@ -25,4 +25,9 @@
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Discord.Net.Webhook.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Loading…
Cancel
Save