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