Skip to content

Commit dbe9efc

Browse files
committed
fix: potential fix for member parsing causing ac to silently fail
1 parent dba4922 commit dbe9efc

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

DisCatSharp/Clients/DiscordClient.Dispatch.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,6 +4096,13 @@ internal async Task OnInteractionCreateAsync(ulong? guildId, ulong channelId, Tr
40964096
c.Value.Discord = this;
40974097
c.Value.Id = c.Key;
40984098
c.Value.GuildId = guildId.Value;
4099+
c.Value.ManualUser = resolved.Users != null && resolved.Users.TryGetValue(c.Key, out var usrResolved)
4100+
? usrResolved
4101+
: new DiscordUser
4102+
{
4103+
Id = c.Key,
4104+
Discord = this
4105+
};
40994106
c.Value.User.Discord = this;
41004107
this.UserCache.AddOrUpdate(c.Value.User.Id, c.Value.User, (old, @new) => @new);
41014108
}

DisCatSharp/Entities/Guild/DiscordMember.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,43 @@ internal DiscordMember(TransportMember mbr)
9898
}
9999

100100
/// <summary>
101-
/// Gets the members avatar hash.
101+
/// Gets the member's guild avatar hash.
102102
/// </summary>
103103
[JsonProperty("avatar", NullValueHandling = NullValueHandling.Ignore)]
104104
public string? GuildAvatarHash { get; internal set; }
105105

106106
/// <summary>
107-
/// Gets the members avatar URL.
107+
/// Gets the member's guild avatar URL.
108108
/// </summary>
109109
[JsonIgnore]
110110
public string GuildAvatarUrl
111111
=> string.IsNullOrWhiteSpace(this.GuildAvatarHash) ? this.User.AvatarUrl : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.GUILDS}/{this.GuildId.ToString(CultureInfo.InvariantCulture)}{Endpoints.USERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}{Endpoints.AVATARS}/{this.GuildAvatarHash}.{(this.GuildAvatarHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}?size=1024";
112112

113113
/// <summary>
114-
/// Gets the members banner hash.
114+
/// Gets the member's guild banner hash.
115115
/// </summary>
116116
[JsonProperty("banner", NullValueHandling = NullValueHandling.Ignore)]
117117
public string? GuildBannerHash { get; internal set; }
118118

119119
/// <summary>
120-
/// Gets the members banner URL.
120+
/// Gets the member's guild banner URL.
121121
/// </summary>
122122
[JsonIgnore]
123123
public string? GuildBannerUrl
124124
=> string.IsNullOrWhiteSpace(this.GuildBannerHash) ? this.User.BannerUrl : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.GUILDS}/{this.GuildId.ToString(CultureInfo.InvariantCulture)}{Endpoints.USERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}{Endpoints.BANNERS}/{this.GuildBannerHash}.{(this.GuildBannerHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}?size=1024";
125125

126126
/// <summary>
127-
/// Gets the members guild avatar decoration data.
127+
/// Gets the member's guild avatar decoration data.
128128
/// </summary>
129129
[JsonProperty("avatar_decoration_data", NullValueHandling = NullValueHandling.Ignore)]
130130
public AvatarDecorationData GuildAvatarDecorationData { get; internal set; }
131131

132+
/// <summary>
133+
/// Gets the members's guild display name styles.
134+
/// </summary>
135+
[JsonProperty("display_name_styles", NullValueHandling = NullValueHandling.Ignore)]
136+
public DisplayNameStyles? GuildDisplayNameStyles { get; internal set; }
137+
132138
/// <summary>
133139
/// The color of this member's banner. Mutually exclusive with <see cref="GuildBannerHash" />.
134140
/// </summary>
@@ -304,6 +310,7 @@ public Permissions Permissions
304310
=> this.InteractionPermissions ?? this.GetPermissions();
305311

306312
/// <inheritdoc />
313+
[JsonIgnore]
307314
public override DisplayNameStyles? DisplayNameStyles
308315
=> this.User.DisplayNameStyles;
309316

0 commit comments

Comments
 (0)