Update for the breaking change discord has made + v3 is cringe (#2951)
* update for the breaking change discord made + v3 is fucked * this could've bee a cool surprise 4 everyone
This commit is contained in:
@@ -20,6 +20,9 @@ public readonly struct ApplicationCommandInteractionMetadata : IMessageInteracti
|
||||
/// <inheritdoc />
|
||||
public ulong UserId { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUser User { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; }
|
||||
|
||||
@@ -32,7 +35,7 @@ public readonly struct ApplicationCommandInteractionMetadata : IMessageInteracti
|
||||
public string Name { get; }
|
||||
|
||||
internal ApplicationCommandInteractionMetadata(ulong id, InteractionType type, ulong userId, IReadOnlyDictionary<ApplicationIntegrationType, ulong> integrationOwners,
|
||||
ulong? originalResponseMessageId, string name)
|
||||
ulong? originalResponseMessageId, string name, IUser user)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
@@ -40,5 +43,6 @@ public readonly struct ApplicationCommandInteractionMetadata : IMessageInteracti
|
||||
IntegrationOwners = integrationOwners;
|
||||
OriginalResponseMessageId = originalResponseMessageId;
|
||||
Name = name;
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ public interface IMessageInteractionMetadata : ISnowflakeEntity
|
||||
/// </summary>
|
||||
ulong UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user who triggered the interaction.
|
||||
/// </summary>
|
||||
IUser User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Ids for installation contexts related to the interaction.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,9 @@ public readonly struct MessageComponentInteractionMetadata : IMessageInteraction
|
||||
/// <inheritdoc />
|
||||
public ulong UserId { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUser User { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; }
|
||||
|
||||
@@ -32,7 +35,7 @@ public readonly struct MessageComponentInteractionMetadata : IMessageInteraction
|
||||
public ulong InteractedMessageId { get; }
|
||||
|
||||
internal MessageComponentInteractionMetadata(ulong id, InteractionType type, ulong userId, IReadOnlyDictionary<ApplicationIntegrationType, ulong> integrationOwners,
|
||||
ulong? originalResponseMessageId, ulong interactedMessageId)
|
||||
ulong? originalResponseMessageId, ulong interactedMessageId, IUser user)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
@@ -40,6 +43,7 @@ public readonly struct MessageComponentInteractionMetadata : IMessageInteraction
|
||||
IntegrationOwners = integrationOwners;
|
||||
OriginalResponseMessageId = originalResponseMessageId;
|
||||
InteractedMessageId = interactedMessageId;
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ public readonly struct ModalSubmitInteractionMetadata :IMessageInteractionMetada
|
||||
/// <inheritdoc />
|
||||
public ulong UserId { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUser User { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; }
|
||||
|
||||
@@ -32,7 +35,7 @@ public readonly struct ModalSubmitInteractionMetadata :IMessageInteractionMetada
|
||||
public IMessageInteractionMetadata TriggeringInteractionMetadata { get; }
|
||||
|
||||
internal ModalSubmitInteractionMetadata(ulong id, InteractionType type, ulong userId, IReadOnlyDictionary<ApplicationIntegrationType, ulong> integrationOwners,
|
||||
ulong? originalResponseMessageId, IMessageInteractionMetadata triggeringInteractionMetadata)
|
||||
ulong? originalResponseMessageId, IMessageInteractionMetadata triggeringInteractionMetadata, IUser user)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
@@ -40,5 +43,6 @@ public readonly struct ModalSubmitInteractionMetadata :IMessageInteractionMetada
|
||||
IntegrationOwners = integrationOwners;
|
||||
OriginalResponseMessageId = originalResponseMessageId;
|
||||
TriggeringInteractionMetadata = triggeringInteractionMetadata;
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ internal class MessageInteractionMetadata
|
||||
|
||||
[JsonProperty("type")]
|
||||
public InteractionType Type { get; set; }
|
||||
|
||||
[JsonProperty("user_id")]
|
||||
public ulong UserId { get; set; }
|
||||
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
|
||||
[JsonProperty("authorizing_integration_owners")]
|
||||
public Dictionary<ApplicationIntegrationType, ulong> IntegrationOwners { get; set; }
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace Discord.Rest
|
||||
if (model.Type == MessageType.Default ||
|
||||
model.Type == MessageType.Reply ||
|
||||
model.Type == MessageType.ApplicationCommand ||
|
||||
model.Type == MessageType.ContextMenuCommand ||
|
||||
model.Type == MessageType.ThreadStarterMessage)
|
||||
return RestUserMessage.Create(discord, channel, author, model);
|
||||
else
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace Discord.Rest
|
||||
ResolvedData = new MessageResolvedData(users, members, roles, channels);
|
||||
}
|
||||
if (model.InteractionMetadata.IsSpecified)
|
||||
InteractionMetadata = model.InteractionMetadata.Value.ToInteractionMetadata();
|
||||
InteractionMetadata = model.InteractionMetadata.Value.ToInteractionMetadata(Discord);
|
||||
|
||||
if (model.Poll.IsSpecified)
|
||||
Poll = model.Poll.Value.ToEntity();
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Discord.Rest;
|
||||
|
||||
internal static class InteractionMetadataExtensions
|
||||
{
|
||||
public static IMessageInteractionMetadata ToInteractionMetadata(this API.MessageInteractionMetadata metadata)
|
||||
public static IMessageInteractionMetadata ToInteractionMetadata(this API.MessageInteractionMetadata metadata, BaseDiscordClient discord)
|
||||
{
|
||||
switch (metadata.Type)
|
||||
{
|
||||
@@ -12,28 +12,31 @@ internal static class InteractionMetadataExtensions
|
||||
return new ApplicationCommandInteractionMetadata(
|
||||
metadata.Id,
|
||||
metadata.Type,
|
||||
metadata.UserId,
|
||||
metadata.User.Id,
|
||||
metadata.IntegrationOwners.ToImmutableDictionary(),
|
||||
metadata.OriginalResponseMessageId.IsSpecified ? metadata.OriginalResponseMessageId.Value : null,
|
||||
metadata.Name.GetValueOrDefault(null));
|
||||
metadata.Name.GetValueOrDefault(null),
|
||||
RestUser.Create(discord, metadata.User));
|
||||
|
||||
case InteractionType.MessageComponent:
|
||||
return new MessageComponentInteractionMetadata(
|
||||
metadata.Id,
|
||||
metadata.Type,
|
||||
metadata.UserId,
|
||||
metadata.User.Id,
|
||||
metadata.IntegrationOwners.ToImmutableDictionary(),
|
||||
metadata.OriginalResponseMessageId.IsSpecified ? metadata.OriginalResponseMessageId.Value : null,
|
||||
metadata.InteractedMessageId.GetValueOrDefault(0));
|
||||
metadata.InteractedMessageId.GetValueOrDefault(0),
|
||||
RestUser.Create(discord, metadata.User));
|
||||
|
||||
case InteractionType.ModalSubmit:
|
||||
return new ModalSubmitInteractionMetadata(
|
||||
metadata.Id,
|
||||
metadata.Type,
|
||||
metadata.UserId,
|
||||
metadata.User.Id,
|
||||
metadata.IntegrationOwners.ToImmutableDictionary(),
|
||||
metadata.OriginalResponseMessageId.IsSpecified ? metadata.OriginalResponseMessageId.Value : null,
|
||||
metadata.TriggeringInteractionMetadata.GetValueOrDefault(null)?.ToInteractionMetadata());
|
||||
metadata.TriggeringInteractionMetadata.GetValueOrDefault(null)?.ToInteractionMetadata(discord),
|
||||
RestUser.Create(discord, metadata.User));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Discord.WebSocket
|
||||
}
|
||||
|
||||
if (model.InteractionMetadata.IsSpecified)
|
||||
InteractionMetadata = model.InteractionMetadata.Value.ToInteractionMetadata();
|
||||
InteractionMetadata = model.InteractionMetadata.Value.ToInteractionMetadata(Discord);
|
||||
|
||||
if (model.Poll.IsSpecified)
|
||||
Poll = model.Poll.Value.ToEntity();
|
||||
|
||||
Reference in New Issue
Block a user