Skip to content

Commit

Permalink
fix: add missing primary_guild field
Browse files Browse the repository at this point in the history
Fixes DISCATSHARP-2EM
Fixes DISCATSHARP-2EK
  • Loading branch information
Lulalaby committed Jan 9, 2025
1 parent ebe051d commit 01f1b20
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions DisCatSharp.Experimental/DiscordApiClientHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ internal async Task<DiscordSearchGuildMembersResponse> SearchGuildMembersAsync(u
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});
}
Expand Down
3 changes: 3 additions & 0 deletions DisCatSharp/Clients/DiscordClient.Dispatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ internal async Task OnReadyEventAsync(ReadyPayload ready, JArray rawGuilds)
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down Expand Up @@ -1971,6 +1972,7 @@ internal async Task OnGuildMemberAddEventAsync(TransportMember member, DiscordGu
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down Expand Up @@ -2045,6 +2047,7 @@ internal async Task OnGuildMemberUpdateEventAsync(TransportMember member, Discor
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down
4 changes: 4 additions & 0 deletions DisCatSharp/Clients/DiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ public async Task<DiscordUser> GetUserAsync(ulong userId, bool fetch = false)
old.Pronouns = usr.Pronouns;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down Expand Up @@ -1624,6 +1625,7 @@ private DiscordUser UpdateUser(DiscordUser usr, ulong? guildId, DiscordGuild? gu
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down Expand Up @@ -1662,6 +1664,7 @@ private DiscordUser UpdateUser(DiscordUser usr, ulong? guildId, DiscordGuild? gu
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down Expand Up @@ -1841,6 +1844,7 @@ private void UpdateCachedGuild(DiscordGuild newGuild, JArray? rawMembers)
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down
1 change: 1 addition & 0 deletions DisCatSharp/Entities/Guild/DiscordGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,7 @@ public async Task<IReadOnlyCollection<DiscordMember>> GetAllMembersAsync()
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});
var mbr = new DiscordMember(xtm)
Expand Down
10 changes: 10 additions & 0 deletions DisCatSharp/Entities/Guild/DiscordMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,16 @@ public override DiscordClan? Clan
internal set => this.User.Clan = value;
}

/// <summary>
/// Gets the member's primary guild.
/// </summary>
[JsonIgnore]
public override DiscordClan? PrimaryGuild
{
get => this.User.PrimaryGuild;
internal set => this.User.PrimaryGuild = value;
}

/// <summary>
/// Gets whether the member is a bot.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions DisCatSharp/Entities/User/DiscordUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ internal DiscordUser(TransportUser transport)
this.Pronouns = transport.Pronouns;
this.GlobalName = transport.GlobalName;
this.Clan = transport.Clan;
this.PrimaryGuild = transport.PrimaryGuild;
}

/// <summary>
Expand Down Expand Up @@ -156,6 +157,12 @@ public string? BannerUrl
[JsonProperty("clan", NullValueHandling = NullValueHandling.Ignore), DiscordUnreleased]
public virtual DiscordClan? Clan { get; internal set; }

/// <summary>
/// Gets the users primary guild.
/// </summary>
[JsonProperty("primary_guild", NullValueHandling = NullValueHandling.Ignore), DiscordUnreleased]
public virtual DiscordClan? PrimaryGuild { get; internal set; }

/// <summary>
/// Gets the user's avatar hash.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions DisCatSharp/Net/Abstractions/Transport/TransportUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ internal string UsernameWithGlobalName
[JsonProperty("clan", NullValueHandling = NullValueHandling.Ignore)]
public DiscordClan? Clan { get; internal set; }

/// <summary>
/// Gets the users primary guild.
/// </summary>
[JsonProperty("primary_guild", NullValueHandling = NullValueHandling.Ignore), DiscordUnreleased]
public DiscordClan? PrimaryGuild { get; internal set; }

/// <summary>
/// Gets the users pronouns.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions DisCatSharp/Net/Rest/DiscordApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ internal async Task<IReadOnlyList<DiscordMember>> SearchGuildMembersAsync(ulong
old.Locale = usr.Locale;
old.GlobalName = usr.GlobalName;
old.Clan = usr.Clan;
old.PrimaryGuild = usr.PrimaryGuild;
return old;
});

Expand Down

0 comments on commit 01f1b20

Please sign in to comment.