Skip to content

Commit

Permalink
feat: set manual user to always provide a user on member
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Jul 21, 2024
1 parent 8302048 commit ffecde9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions DisCatSharp/Entities/Guild/DiscordMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ internal DiscordMember(DiscordUser user)

this.Id = user.Id;

this.ManualUser = user;

this.RoleIdsInternal = [];
this._roleIdsLazy = new(() => new ReadOnlyCollection<ulong>(this.RoleIdsInternal));
}
Expand Down Expand Up @@ -68,6 +70,11 @@ internal DiscordMember(TransportMember mbr)
this.MemberFlags = mbr.MemberFlags;
this.InteractionPermissions = mbr.Permissions;
this.GuildAvatarDecorationData = mbr.GuildAvatarDecorationData;
if (mbr.User is not null)
this.ManualUser = new(mbr.User)
{
Discord = this.Discord
};
}

/// <summary>
Expand Down Expand Up @@ -162,15 +169,15 @@ public IReadOnlyList<ulong> RoleIds

/// <summary>
/// Gets the list of roles associated with this member.
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public IReadOnlyList<DiscordRole> Roles
=> this.RoleIds.Select(id => this.Guild.GetRole(id)).Where(x => x is not null).ToList();

/// <summary>
/// Gets the color associated with this user's top color-giving role, otherwise 0 (no color).
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public DiscordColor Color
Expand Down Expand Up @@ -240,7 +247,7 @@ public bool HasUnusualDmActivity

/// <summary>
/// Gets this member's voice state.
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public DiscordVoiceState? VoiceState
Expand All @@ -254,15 +261,15 @@ public DiscordVoiceState? VoiceState

/// <summary>
/// Gets the guild of which this member is a part of.
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public DiscordGuild Guild
=> this.Discord.Guilds[this.GuildId];

/// <summary>
/// Gets whether this member is the Guild owner.
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public bool IsOwner
Expand All @@ -287,7 +294,7 @@ public int Hierarchy

/// <summary>
/// Gets the permissions for the current member.
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// <note type="warning">This will throw if accessed for an oauth2 constructed member.</note>
/// </summary>
[JsonIgnore]
public Permissions Permissions
Expand Down

0 comments on commit ffecde9

Please sign in to comment.