|
@@ -52,19 +52,37 @@ namespace Discord.Rest |
|
|
public bool IsValidToken |
|
|
public bool IsValidToken |
|
|
=> InteractionHelper.CanRespondOrFollowup(this); |
|
|
=> InteractionHelper.CanRespondOrFollowup(this); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// Gets the ID of the channel this interaction was executed in. |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <remarks> |
|
|
|
|
|
/// <see langword="null"/> if the interaction was not executed in a guild. |
|
|
|
|
|
/// </remarks> |
|
|
|
|
|
public ulong? ChannelId { get; private set; } = null; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// Gets the channel that this interaction was executed in. |
|
|
/// Gets the channel that this interaction was executed in. |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <remarks> |
|
|
/// <remarks> |
|
|
/// <see langword="null"/> if <see cref="DiscordRestConfig.APIOnRestInteractionCreation"/> is set to false. |
|
|
|
|
|
|
|
|
/// <see langword="null"/> if <see cref="DiscordRestConfig.APIOnRestInteractionCreation"/> is set to false |
|
|
|
|
|
/// or if the interaction was not executed in a guild. |
|
|
/// </remarks> |
|
|
/// </remarks> |
|
|
public IRestMessageChannel Channel { get; private set; } |
|
|
public IRestMessageChannel Channel { get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// Gets the ID of the guild this interaction was executed in if applicable. |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <remarks> |
|
|
|
|
|
/// <see langword="null"/> if the interaction was not executed in a guild. |
|
|
|
|
|
/// </remarks> |
|
|
|
|
|
public ulong? GuildId { get; private set; } = null; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// Gets the guild this interaction was executed in if applicable. |
|
|
/// Gets the guild this interaction was executed in if applicable. |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <remarks> |
|
|
/// <remarks> |
|
|
/// <see langword="null"/> if <see cref="DiscordRestConfig.APIOnRestInteractionCreation"/> is set to false. |
|
|
|
|
|
|
|
|
/// This property will be <see langword="null"/> if <see cref="DiscordRestConfig.APIOnRestInteractionCreation"/> is set to false |
|
|
|
|
|
/// or if the interaction was not executed in a guild. |
|
|
/// </remarks> |
|
|
/// </remarks> |
|
|
public RestGuild Guild { get; private set; } |
|
|
public RestGuild Guild { get; private set; } |
|
|
|
|
|
|
|
@@ -130,8 +148,9 @@ namespace Discord.Rest |
|
|
Version = model.Version; |
|
|
Version = model.Version; |
|
|
Type = model.Type; |
|
|
Type = model.Type; |
|
|
|
|
|
|
|
|
if(Guild == null && model.GuildId.IsSpecified) |
|
|
|
|
|
|
|
|
if (Guild == null && model.GuildId.IsSpecified) |
|
|
{ |
|
|
{ |
|
|
|
|
|
GuildId = model.GuildId.Value; |
|
|
if (discord.APIOnInteractionCreation) |
|
|
if (discord.APIOnInteractionCreation) |
|
|
Guild = await discord.GetGuildAsync(model.GuildId.Value); |
|
|
Guild = await discord.GetGuildAsync(model.GuildId.Value); |
|
|
else |
|
|
else |
|
@@ -150,21 +169,23 @@ namespace Discord.Rest |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(Channel == null && model.ChannelId.IsSpecified) |
|
|
|
|
|
|
|
|
if (Channel == null && model.ChannelId.IsSpecified) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
|
|
|
ChannelId = model.ChannelId.Value; |
|
|
if (discord.APIOnInteractionCreation) |
|
|
if (discord.APIOnInteractionCreation) |
|
|
Channel = (IRestMessageChannel)await discord.GetChannelAsync(model.ChannelId.Value); |
|
|
Channel = (IRestMessageChannel)await discord.GetChannelAsync(model.ChannelId.Value); |
|
|
else |
|
|
else |
|
|
Channel = null; |
|
|
Channel = null; |
|
|
} |
|
|
} |
|
|
catch(HttpException x) when(x.DiscordCode == DiscordErrorCode.MissingPermissions) { } // ignore |
|
|
|
|
|
|
|
|
catch (HttpException x) when (x.DiscordCode == DiscordErrorCode.MissingPermissions) { } // ignore |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
UserLocale = model.UserLocale.IsSpecified |
|
|
UserLocale = model.UserLocale.IsSpecified |
|
|
? model.UserLocale.Value |
|
|
|
|
|
: null; |
|
|
|
|
|
|
|
|
? model.UserLocale.Value |
|
|
|
|
|
: null; |
|
|
|
|
|
|
|
|
GuildLocale = model.GuildLocale.IsSpecified |
|
|
GuildLocale = model.GuildLocale.IsSpecified |
|
|
? model.GuildLocale.Value |
|
|
? model.GuildLocale.Value |
|
|
: null; |
|
|
: null; |
|
@@ -180,6 +201,9 @@ namespace Discord.Rest |
|
|
return json.ToString(); |
|
|
return json.ToString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<RestGuild> GetGuildAsync() |
|
|
|
|
|
=> await |
|
|
|
|
|
|
|
|
/// <inheritdoc/> |
|
|
/// <inheritdoc/> |
|
|
public abstract string Defer(bool ephemeral = false, RequestOptions options = null); |
|
|
public abstract string Defer(bool ephemeral = false, RequestOptions options = null); |
|
|
/// <summary> |
|
|
/// <summary> |
|
|