diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
index 9b4e435cf..f9e34362c 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
@@ -58,7 +58,7 @@ namespace Discord
public bool? Required { get; set; }
///
- /// choices for string and int types for the user to pick from
+ /// choices for string and int types for the user to pick from.
///
public List Choices { get; set; }
diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs
index 99e3f66d6..53332c74b 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs
@@ -7,14 +7,14 @@ using System.Threading.Tasks;
namespace Discord
{
///
- /// Represents a choice for a . This class is used when making new commands
+ /// Represents a choice for a . This class is used when making new commands.
///
public class ApplicationCommandOptionChoiceProperties
{
private string _name;
private object _value;
///
- /// The name of this choice
+ /// The name of this choice.
///
public string Name
{
@@ -30,7 +30,7 @@ namespace Discord
// Note: discord allows strings & ints as values. how should that be handled?
// should we make this an object and then just type check it?
///
- /// The value of this choice
+ /// The value of this choice.
///
public object Value
{
diff --git a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs
index c094efbd8..cf1395328 100644
--- a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs
@@ -40,7 +40,7 @@ namespace Discord
/// Deletes this command
///
/// The options to be used when sending the request.
- ///
+ /// A task that represents the asynchronous delete operation.
Task DeleteAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionData.cs b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionData.cs
index 6f700d898..ec452180a 100644
--- a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionData.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionData.cs
@@ -7,22 +7,22 @@ using System.Threading.Tasks;
namespace Discord
{
///
- /// Represents data of an Interaction Command, see
+ /// Represents data of an Interaction Command, see .
///
public interface IApplicationCommandInteractionData
{
///
- /// The snowflake id of this command
+ /// The snowflake id of this command.
///
ulong Id { get; }
///
- /// The name of this command
+ /// The name of this command.
///
string Name { get; }
///
- /// The params + values from the user
+ /// The params + values from the user.
///
IReadOnlyCollection Options { get; }
}
diff --git a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionDataOption.cs b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionDataOption.cs
index 8ea8378e7..ffc94c428 100644
--- a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionDataOption.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandInteractionDataOption.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Discord
{
///
- /// Represents a option group for a command, see
+ /// Represents a option group for a command, see .
///
public interface IApplicationCommandInteractionDataOption
{
diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommandCreationProperties.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommandCreationProperties.cs
index 0facc02a1..df9f39809 100644
--- a/src/Discord.Net.Core/Entities/Interactions/SlashCommandCreationProperties.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommandCreationProperties.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Discord
{
///
- /// A class used to create slash commands
+ /// A class used to create slash commands.
///
public class SlashCommandCreationProperties
{
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs
index 5e0852b29..67a530d50 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs
@@ -9,20 +9,30 @@ using Model = Discord.API.ApplicationCommand;
namespace Discord.Rest
{
///
- /// Represents a rest implementation of the
+ /// Represents a Rest-based implementation of the .
///
public abstract class RestApplicationCommand : RestEntity, IApplicationCommand
{
+ ///
public ulong ApplicationId { get; private set; }
+ ///
public string Name { get; private set; }
+ ///
public string Description { get; private set; }
+ ///
+ /// The options of this command.
+ ///
public IReadOnlyCollection Options { get; private set; }
+ ///
+ /// The type of this rest application command.
+ ///
public RestApplicationCommandType CommandType { get; internal set; }
+ ///
public DateTimeOffset CreatedAt
=> SnowflakeUtils.FromSnowflake(this.Id);
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs
index f9ab50f60..902afdd44 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs
@@ -7,10 +7,15 @@ using Model = Discord.API.ApplicationCommandOptionChoice;
namespace Discord.Rest
{
+ ///
+ /// Represents a Rest-based implementation of .
+ ///
public class RestApplicationCommandChoice : IApplicationCommandOptionChoice
{
+ ///
public string Name { get; }
+ ///
public object Value { get; }
internal RestApplicationCommandChoice(Model model)
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs
index 120fe0c29..a8e37873e 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs
@@ -8,20 +8,34 @@ using Model = Discord.API.ApplicationCommandOption;
namespace Discord.Rest
{
+ ///
+ /// Represents a Rest-based implementation of .
+ ///
public class RestApplicationCommandOption : IApplicationCommandOption
{
+ ///
public ApplicationCommandOptionType Type { get; private set; }
+ ///
public string Name { get; private set; }
+ ///
public string Description { get; private set; }
+ ///
public bool? Default { get; private set; }
+ ///
public bool? Required { get; private set; }
+ ///
+ /// A collection of 's for this command.
+ ///
public IReadOnlyCollection Choices { get; private set; }
+ ///
+ /// A collection of 's for this command.
+ ///
public IReadOnlyCollection Options { get; private set; }
internal RestApplicationCommandOption() { }
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandType.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandType.cs
index 7ea7cd9f0..96ba07053 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandType.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandType.cs
@@ -6,9 +6,19 @@ using System.Threading.Tasks;
namespace Discord.Rest
{
+ ///
+ /// Represents a type of Rest-based command.
+ ///
public enum RestApplicationCommandType
{
+ ///
+ /// Specifies that this command is a Global command.
+ ///
GlobalCommand,
+
+ ///
+ /// Specifies that this command is a Guild specific command.
+ ///
GuildCommand
}
}
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs
index 5223c069c..230243c7a 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs
@@ -8,7 +8,7 @@ using Model = Discord.API.ApplicationCommand;
namespace Discord.Rest
{
///
- /// Represents a global Slash command
+ /// Represents a global Slash command.
///
public class RestGlobalCommand : RestApplicationCommand
{
@@ -24,6 +24,8 @@ namespace Discord.Rest
entity.Update(model);
return entity;
}
+
+ ///
public override async Task DeleteAsync(RequestOptions options = null)
=> await InteractionHelper.DeleteGlobalCommand(Discord, this).ConfigureAwait(false);
@@ -33,7 +35,7 @@ namespace Discord.Rest
/// The delegate containing the properties to modify the command with.
/// The options to be used when sending the request.
///
- /// The modified command
+ /// The modified command.
///
public async Task ModifyAsync(Action func, RequestOptions options = null)
=> await InteractionHelper.ModifyGlobalCommand(Discord, this, func, options).ConfigureAwait(false);
diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs
index 73737dcd2..5e0efbf8d 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs
@@ -7,9 +7,16 @@ using Model = Discord.API.ApplicationCommand;
namespace Discord.Rest
{
+ ///
+ /// Represents a Rest-based guild command.
+ ///
public class RestGuildCommand : RestApplicationCommand
{
+ ///
+ /// The guild Id where this command originates.
+ ///
public ulong GuildId { get; set; }
+
internal RestGuildCommand(BaseDiscordClient client, ulong id, ulong guildId)
: base(client, id)
{
@@ -24,6 +31,7 @@ namespace Discord.Rest
return entity;
}
+ ///
public override async Task DeleteAsync(RequestOptions options = null)
=> await InteractionHelper.DeleteGuildCommand(Discord, this).ConfigureAwait(false);
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommand.cs
index c8cc4d3a2..3c44fa991 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommand.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommand.cs
@@ -8,19 +8,31 @@ using Model = Discord.API.Gateway.ApplicationCommandCreatedUpdatedEvent;
namespace Discord.WebSocket
{
+ ///
+ /// Represends a Websocket-based recieved over the gateway.
+ ///
public class SocketApplicationCommand : SocketEntity, IApplicationCommand
{
+ ///
public ulong ApplicationId { get; private set; }
+ ///
public string Name { get; private set; }
+ ///
public string Description { get; private set; }
+ ///
+ /// A collection of 's recieved over the gateway.
+ ///
public IReadOnlyCollection Options { get; private set; }
public DateTimeOffset CreatedAt
=> SnowflakeUtils.FromSnowflake(this.Id);
+ ///
+ /// The where this application was created.
+ ///
public SocketGuild Guild
=> Discord.GetGuild(this.GuildId);
private ulong GuildId { get; set; }
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandChoice.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandChoice.cs
index f82f9e6c4..e9809b7ba 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandChoice.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandChoice.cs
@@ -8,12 +8,14 @@ using Model = Discord.API.ApplicationCommandOptionChoice;
namespace Discord.WebSocket
{
///
- /// Represents a choice for a
+ /// Represents a choice for a .
///
public class SocketApplicationCommandChoice : IApplicationCommandOptionChoice
{
+ ///
public string Name { get; private set; }
+ ///
public object Value { get; private set; }
internal SocketApplicationCommandChoice() { }
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs
index e856bce42..0a90a8073 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs
@@ -9,18 +9,23 @@ using Model = Discord.API.ApplicationCommandOption;
namespace Discord.WebSocket
{
///
- /// Represents an option for a
+ /// Represents an option for a .
///
public class SocketApplicationCommandOption : IApplicationCommandOption
{
+ ///
public string Name { get; private set; }
+ ///
public ApplicationCommandOptionType Type { get; private set; }
+ ///
public string Description { get; private set; }
+ ///
public bool? Default { get; private set; }
+ ///
public bool? Required { get; private set; }
///
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
index f8c2c62bd..4a8277fd4 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
@@ -9,52 +9,52 @@ using Model = Discord.API.Gateway.InteractionCreated;
namespace Discord.WebSocket
{
///
- /// Represents an Interaction recieved over the gateway
+ /// Represents an Interaction recieved over the gateway.
///
public class SocketInteraction : SocketEntity, IDiscordInteraction
{
///
- /// The this interaction was used in
+ /// The this interaction was used in.
///
public SocketGuild Guild
=> Discord.GetGuild(GuildId);
///
- /// The this interaction was used in
+ /// The this interaction was used in.
///
public SocketTextChannel Channel
=> Guild.GetTextChannel(ChannelId);
///
- /// The who triggered this interaction
+ /// The who triggered this interaction.
///
public SocketGuildUser Member
=> Guild.GetUser(MemberId);
///
- /// The type of this interaction
+ /// The type of this interaction.
///
public InteractionType Type { get; private set; }
///
- /// The data associated with this interaction
+ /// The data associated with this interaction.
///
public SocketInteractionData Data { get; private set; }
///
- /// The token used to respond to this interaction
+ /// The token used to respond to this interaction.
///
public string Token { get; private set; }
///
- /// The version of this interaction
+ /// The version of this interaction.
///
public int Version { get; private set; }
public DateTimeOffset CreatedAt { get; }
///
- /// if the token is valid for replying to, otherwise
+ /// if the token is valid for replying to, otherwise .
///
public bool IsValidToken
=> CheckToken();
@@ -78,7 +78,7 @@ namespace Discord.WebSocket
internal void Update(Model model)
{
this.Data = model.Data.IsSpecified
- ? SocketInteractionData.Create(this.Discord, model.Data.Value)
+ ? SocketInteractionData.Create(this.Discord, model.Data.Value, model.GuildId)
: null;
this.GuildId = model.GuildId;
@@ -101,17 +101,17 @@ namespace Discord.WebSocket
/// instead.
///
///
- /// The text of the message to be sent
- /// if the message should be read out by a text-to-speech reader, otherwise
- /// A to send with this response
- /// The type of response to this Interaction
- /// The allowed mentions for this response
- /// The request options for this response
+ /// The text of the message to be sent.
+ /// if the message should be read out by a text-to-speech reader, otherwise .
+ /// A to send with this response.
+ /// The type of response to this Interaction.
+ /// The allowed mentions for this response.
+ /// The request options for this response.
///
- /// The sent as the response. If this is the first acknowledgement, it will return null;
+ /// The sent as the response. If this is the first acknowledgement, it will return null.
///
/// Message content is too long, length must be less or equal to .
- /// The parameters provided were invalid or the token was invalid
+ /// The parameters provided were invalid or the token was invalid.
public async Task RespondAsync(string text = null, bool isTTS = false, Embed embed = null, InteractionResponseType Type = InteractionResponseType.ChannelMessageWithSource, AllowedMentions allowedMentions = null, RequestOptions options = null)
{
@@ -162,16 +162,16 @@ namespace Discord.WebSocket
}
///
- /// Sends a followup message for this interaction
+ /// Sends a followup message for this interaction.
///
/// The text of the message to be sent
- /// if the message should be read out by a text-to-speech reader, otherwise
- /// A to send with this response
- /// The type of response to this Interaction
- /// The allowed mentions for this response
- /// The request options for this response
+ /// if the message should be read out by a text-to-speech reader, otherwise .
+ /// A to send with this response.
+ /// The type of response to this Interaction.
+ /// The allowed mentions for this response.
+ /// The request options for this response.
///
- /// The sent message
+ /// The sent message.
///
public async Task FollowupAsync(string text = null, bool isTTS = false, Embed embed = null, InteractionResponseType Type = InteractionResponseType.ChannelMessageWithSource,
AllowedMentions allowedMentions = null, RequestOptions options = null)
@@ -195,10 +195,10 @@ namespace Discord.WebSocket
}
///
- /// Acknowledges this interaction with the
+ /// Acknowledges this interaction with the .
///
///
- /// A task that represents the asynchronous operation of acknowledging the interaction
+ /// A task that represents the asynchronous operation of acknowledging the interaction.
///
public async Task AcknowledgeAsync(RequestOptions options = null)
{
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs
index b6dfd2f8e..eef7e5ab4 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs
@@ -10,28 +10,36 @@ namespace Discord.WebSocket
{
public class SocketInteractionData : SocketEntity, IApplicationCommandInteractionData
{
+ ///
public string Name { get; private set; }
+
+ ///
+ /// The 's recieved with this interaction.
+ ///
public IReadOnlyCollection Options { get; private set; }
+ private ulong guildId;
+
internal SocketInteractionData(DiscordSocketClient client, ulong id)
: base(client, id)
{
}
- internal static SocketInteractionData Create(DiscordSocketClient client, Model model)
+ internal static SocketInteractionData Create(DiscordSocketClient client, Model model, ulong guildId)
{
var entity = new SocketInteractionData(client, model.Id);
- entity.Update(model);
+ entity.Update(model, guildId);
return entity;
}
- internal void Update(Model model)
+ internal void Update(Model model, ulong guildId)
{
this.Name = model.Name;
+ this.guildId = guildId;
+
this.Options = model.Options.IsSpecified
- ? model.Options.Value.Select(x => new SocketInteractionDataOption(x)).ToImmutableArray()
+ ? model.Options.Value.Select(x => new SocketInteractionDataOption(x, this.Discord, guildId)).ToImmutableArray()
: null;
-
}
IReadOnlyCollection IApplicationCommandInteractionData.Options => Options;
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs
index 26a7b9659..62097689d 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs
@@ -8,21 +8,91 @@ using Model = Discord.API.ApplicationCommandInteractionDataOption;
namespace Discord.WebSocket
{
+ ///
+ /// Represents a Websocket-based recieved by the gateway
+ ///
public class SocketInteractionDataOption : IApplicationCommandInteractionDataOption
{
+ ///
public string Name { get; private set; }
- public object? Value { get; private set; }
- public IReadOnlyCollection Options { get; private set; }
+ ///
+ public object Value { get; private set; }
- internal SocketInteractionDataOption(Model model)
+ ///
+ /// The sub command options recieved for this sub command group.
+ ///
+ public IReadOnlyCollection Options { get; private set; }
+
+ private DiscordSocketClient discord;
+ private ulong guild;
+
+ internal SocketInteractionDataOption() { }
+ internal SocketInteractionDataOption(Model model, DiscordSocketClient discord, ulong guild)
{
this.Name = Name;
this.Value = model.Value.IsSpecified ? model.Value.Value : null;
+ this.discord = discord;
+ this.guild = guild;
this.Options = model.Options.IsSpecified
- ? model.Options.Value.Select(x => new SocketInteractionDataOption(x)).ToImmutableArray()
+ ? model.Options.Value.Select(x => new SocketInteractionDataOption(x, discord, guild)).ToImmutableArray()
: null;
}
+
+ // Converters
+ public static explicit operator bool(SocketInteractionDataOption option)
+ => (bool)option.Value;
+ public static explicit operator int(SocketInteractionDataOption option)
+ => (int)option.Value;
+ public static explicit operator string(SocketInteractionDataOption option)
+ => option.Value.ToString();
+
+ public static explicit operator SocketGuildChannel(SocketInteractionDataOption option)
+ {
+ if (option.Value is ulong id)
+ {
+ var guild = option.discord.GetGuild(option.guild);
+
+ if (guild == null)
+ return null;
+
+ return guild.GetChannel(id);
+ }
+
+ return null;
+ }
+
+ public static explicit operator SocketRole(SocketInteractionDataOption option)
+ {
+ if (option.Value is ulong id)
+ {
+ var guild = option.discord.GetGuild(option.guild);
+
+ if (guild == null)
+ return null;
+
+ return guild.GetRole(id);
+ }
+
+ return null;
+ }
+
+ public static explicit operator SocketGuildUser(SocketInteractionDataOption option)
+ {
+ if(option.Value is ulong id)
+ {
+ var guild = option.discord.GetGuild(option.guild);
+
+ if (guild == null)
+ return null;
+
+ return guild.GetUser(id);
+ }
+
+ return null;
+ }
+
+ IReadOnlyCollection IApplicationCommandInteractionDataOption.Options => this.Options;
}
}