Skip to content

Commit

Permalink
feat: message.interaction_metadata has user instead of user_id now
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Apr 23, 2024
1 parent cc0eff7 commit 299cf0c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
17 changes: 14 additions & 3 deletions DisCatSharp/Entities/Interaction/DiscordInteractionMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DisCatSharp.Enums;
using DisCatSharp.Net.Abstractions;

using Newtonsoft.Json;

Expand All @@ -16,10 +17,20 @@ public sealed class DiscordInteractionMetadata : SnowflakeObject
public InteractionType Type { get; internal set; }

/// <summary>
/// User ID of the user who triggered the interaction.
/// The transport user who triggered the interaction.
/// </summary>
[JsonProperty("user_id")]
public ulong UserId { get; internal set; }
[JsonProperty("user")]
internal TransportUser TransportUser { get; set; }

/// <summary>
/// Ther user who triggered the interaction.
/// </summary>
[JsonIgnore]
public DiscordUser User
=> new(this.TransportUser)
{
Discord = this.Discord
};

/// <summary>
/// This is the same field on interaction.
Expand Down
12 changes: 7 additions & 5 deletions DisCatSharp/Entities/Message/DiscordMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ internal DiscordMessage(DiscordMessage other)
this.Resolved = other.Resolved;
this.Interaction = other.Interaction;
this.InteractionMetadata = other.InteractionMetadata;
if (other.InteractionMetadata is not null && this.InteractionMetadata is not null)
this.InteractionMetadata.Discord = other.InteractionMetadata.Discord;
this.Poll = other.Poll;
if (this.Poll is not null)
{
this.Poll.ChannelId = this.ChannelId;
this.Poll.MessageId = this.Id;
}
if (this.Poll is null)
return;

this.Poll.ChannelId = this.ChannelId;
this.Poll.MessageId = this.Id;
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions DisCatSharp/Net/Rest/DiscordApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ private void PopulateMessage(TransportUser author, DiscordMessage ret)

if (ret.Poll is not null)
ret.Poll.Discord = this.Discord;

if (ret.InteractionMetadata is not null)
ret.InteractionMetadata.Discord = this.Discord;
}

/// <summary>
Expand Down

0 comments on commit 299cf0c

Please sign in to comment.