@@ -25,5 +25,10 @@ | |||||
<PackagePath></PackagePath> | <PackagePath></PackagePath> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<None Update="Discord.Net.Commands.xml"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -32,4 +32,9 @@ | |||||
<PackagePath></PackagePath> | <PackagePath></PackagePath> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<None Update="Discord.Net.Core.xml"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -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; } | |||||
} | |||||
} |
@@ -30,4 +30,9 @@ | |||||
<PackagePath></PackagePath> | <PackagePath></PackagePath> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<None Update="Discord.Net.Rest.xml"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -25,6 +25,6 @@ namespace Discord.API.Gateway | |||||
public ulong GuildId { get; set; } | public ulong GuildId { get; set; } | ||||
[JsonProperty("options")] | [JsonProperty("options")] | ||||
public List<Discord.API.ApplicationCommandOption> Options { get; set; } | |||||
public Optional<List<Discord.API.ApplicationCommandOption>> Options { get; set; } | |||||
} | } | ||||
} | } |
@@ -27,4 +27,9 @@ | |||||
<PackagePath></PackagePath> | <PackagePath></PackagePath> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<None Update="Discord.Net.WebSocket.xml"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -56,8 +56,8 @@ namespace Discord.WebSocket | |||||
this.Name = model.Name; | this.Name = model.Name; | ||||
this.GuildId = model.GuildId; | 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>(); | : new ImmutableArray<SocketApplicationCommandOption>(); | ||||
} | } | ||||
@@ -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; | |||||
} | |||||
} | |||||
} |
@@ -25,4 +25,9 @@ | |||||
<PackagePath></PackagePath> | <PackagePath></PackagePath> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<None Update="Discord.Net.Webhook.xml"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |