Skip to content

Commit

Permalink
[Feature] Add missing remove property to MemberRoleAudit (#2675)
Browse files Browse the repository at this point in the history
* Adding the missing remove property to MemberRoleAudit

* fix

* Update src/Discord.Net.WebSocket/Entities/AuditLogs/DataTypes/SocketMemberRoleEditInfo.cs

Co-authored-by: Quin Lynch <[email protected]>

* Update src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleEditInfo.cs

Co-authored-by: Quin Lynch <[email protected]>

---------

Co-authored-by: Quin Lynch <[email protected]>
  • Loading branch information
1NieR and quinchs authored Aug 10, 2023
1 parent c922497 commit 5fb9152
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static MemberRoleAuditLogData Create(BaseDiscordClient discord, EntryMo

var roleInfos = changes.SelectMany(x => x.NewValue.ToObject<API.Role[]>(discord.ApiClient.Serializer),
(model, role) => new { model.ChangedProperty, Role = role })
.Select(x => new MemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add"))
.Select(x => new MemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add", x.ChangedProperty == "$remove"))
.ToList();

var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ namespace Discord.Rest;
/// </summary>
public struct MemberRoleEditInfo
{
internal MemberRoleEditInfo(string name, ulong roleId, bool added)
internal MemberRoleEditInfo(string name, ulong roleId, bool added, bool removed)
{
Name = name;
RoleId = roleId;
Added = added;
Removed = removed;
}

/// <summary>
Expand All @@ -35,4 +36,11 @@ internal MemberRoleEditInfo(string name, ulong roleId, bool added)
/// <see langword="true" /> if the role was added to the user; otherwise <see langword="false" />.
/// </returns>
public bool Added { get; }
/// <summary>
/// Gets a value indicating that the user role has been removed.
/// </summary>
/// <returns>
/// <c>true</c> if the role has been removed from the user; otherwise <c>false</c>.
/// </returns>
public bool Removed { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static SocketMemberRoleAuditLogData Create(DiscordSocketClient discord,

var roleInfos = changes.SelectMany(x => x.NewValue.ToObject<API.Role[]>(discord.ApiClient.Serializer),
(model, role) => new { model.ChangedProperty, Role = role })
.Select(x => new SocketMemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add"))
.Select(x => new SocketMemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add", x.ChangedProperty == "$remove"))
.ToList();

var cachedUser = discord.GetUser(entry.TargetId!.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ namespace Discord.WebSocket;
/// </summary>
public struct SocketMemberRoleEditInfo
{
internal SocketMemberRoleEditInfo(string name, ulong roleId, bool added)
internal SocketMemberRoleEditInfo(string name, ulong roleId, bool added, bool removed)
{
Name = name;
RoleId = roleId;
Added = added;
Removed = removed;
}

/// <summary>
Expand All @@ -33,4 +34,11 @@ internal SocketMemberRoleEditInfo(string name, ulong roleId, bool added)
/// <see langword="true" /> if the role was added to the user; otherwise <see langword="false" />.
/// </returns>
public bool Added { get; }
/// <summary>
/// Gets a value indicating that the user role has been removed.
/// </summary>
/// <returns>
/// <c>true</c> if the role has been removed from the user; otherwise <c>false</c>.
/// </returns>
public bool Removed { get; }
}

0 comments on commit 5fb9152

Please sign in to comment.