Browse Source

Merge branch 'Interactions' of https://github.com/Discord-Net-Labs/Discord.Net-Labs into Interactions

pull/1923/head
quin lynch 4 years ago
parent
commit
6855b7909f
6 changed files with 11 additions and 26 deletions
  1. +1
    -5
      src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionData.cs
  2. +1
    -5
      src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs
  3. +1
    -1
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  4. +1
    -3
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
  5. +4
    -6
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs
  6. +3
    -6
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs

+ 1
- 5
src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionData.cs View File

@@ -1,9 +1,5 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord.API
{
@@ -16,6 +12,6 @@ namespace Discord.API
public string Name { get; set; }

[JsonProperty("options")]
public Optional<ApplicationCommandInteractionDataOption[]> Options { get; set; }
public List<ApplicationCommandInteractionDataOption> Options { get; set; } = new();
}
}

+ 1
- 5
src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs View File

@@ -1,9 +1,5 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord.API
{
@@ -16,6 +12,6 @@ namespace Discord.API
public Optional<object> Value { get; set; }

[JsonProperty("options")]
public Optional<IEnumerable<ApplicationCommandInteractionDataOption>> Options { get; set; }
public List<ApplicationCommandInteractionDataOption> Options { get; set; } = new();
}
}

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

@@ -956,7 +956,7 @@ namespace Discord.API

options = RequestOptions.CreateOrClone(options);

return await SendAsync<Message>("GET", $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original").ConfigureAwait(false);
return await SendAsync<Message>("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task ModifyInteractionResponse(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null)
{


+ 1
- 3
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs View File

@@ -1,12 +1,10 @@
using Discord.Rest;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.Gateway.InteractionCreated;
using DataModel = Discord.API.ApplicationCommandInteractionData;
using Model = Discord.API.Gateway.InteractionCreated;

namespace Discord.WebSocket
{


+ 4
- 6
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs View File

@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.ApplicationCommandInteractionData;

namespace Discord.WebSocket
@@ -14,7 +11,7 @@ namespace Discord.WebSocket
public string Name { get; private set; }

/// <summary>
/// The <see cref="SocketSlashCommandDataOption"/>'s recieved with this interaction.
/// The <see cref="SocketSlashCommandDataOption"/>'s received with this interaction.
/// </summary>
public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; }

@@ -33,8 +30,9 @@ namespace Discord.WebSocket
internal void Update(Model model)
{
this.Name = model.Name;
this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketSlashCommandDataOption(x, this.Discord)).ToImmutableArray()

this.Options = model.Options.Any()
? model.Options.Select(x => new SocketSlashCommandDataOption(x, this.Discord)).ToImmutableArray()
: null;
}



+ 3
- 6
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs View File

@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.ApplicationCommandInteractionDataOption;

namespace Discord.WebSocket
@@ -20,7 +17,7 @@ namespace Discord.WebSocket
public object Value { get; private set; }

/// <summary>
/// The sub command options recieved for this sub command group.
/// The sub command options received for this sub command group.
/// </summary>
public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; }

@@ -33,8 +30,8 @@ namespace Discord.WebSocket
this.Value = model.Value.IsSpecified ? model.Value.Value : null;
this.discord = discord;

this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketSlashCommandDataOption(x, discord)).ToImmutableArray()
this.Options = model.Options.Any()
? model.Options.Select(x => new SocketSlashCommandDataOption(x, discord)).ToImmutableArray()
: null;
}



Loading…
Cancel
Save