[Feature] Audit log integration type (#2814)

* why do I do this instead of preparing for an exam

* oh yeah nullable ofc

* oh yeah
This commit is contained in:
Mihail Gribkov
2023-12-26 01:34:25 +03:00
committed by GitHub
parent 079a98fbdd
commit d382e5cd48
5 changed files with 35 additions and 8 deletions

View File

@@ -9,9 +9,10 @@ namespace Discord.WebSocket;
/// </summary>
public class SocketKickAuditLogData : ISocketAuditLogData
{
private SocketKickAuditLogData(Cacheable<SocketUser, RestUser, IUser, ulong> user)
private SocketKickAuditLogData(Cacheable<SocketUser, RestUser, IUser, ulong> user, string integrationType)
{
Target = user;
IntegrationType = integrationType;
}
internal static SocketKickAuditLogData Create(DiscordSocketClient discord, EntryModel entry)
@@ -26,7 +27,7 @@ public class SocketKickAuditLogData : ISocketAuditLogData
var user = await discord.ApiClient.GetUserAsync(entry.TargetId!.Value);
return user is not null ? RestUser.Create(discord, user) : null;
});
return new SocketKickAuditLogData(cacheableUser);
return new SocketKickAuditLogData(cacheableUser, entry.Options?.IntegrationType);
}
/// <summary>
@@ -40,4 +41,9 @@ public class SocketKickAuditLogData : ISocketAuditLogData
/// A cacheable user object representing the kicked user.
/// </returns>
public Cacheable<SocketUser, RestUser, IUser, ulong> Target { get; }
/// <summary>
/// Gets the type of integration which performed the action. <see langword="null"/> if the action was performed by a user.
/// </summary>
public string IntegrationType { get; }
}

View File

@@ -10,10 +10,11 @@ namespace Discord.WebSocket;
/// </summary>
public class SocketMemberRoleAuditLogData : ISocketAuditLogData
{
private SocketMemberRoleAuditLogData(IReadOnlyCollection<SocketMemberRoleEditInfo> roles, Cacheable<SocketUser, RestUser, IUser, ulong> target)
private SocketMemberRoleAuditLogData(IReadOnlyCollection<SocketMemberRoleEditInfo> roles, Cacheable<SocketUser, RestUser, IUser, ulong> target, string integrationType)
{
Roles = roles;
Target = target;
IntegrationType = integrationType;
}
internal static SocketMemberRoleAuditLogData Create(DiscordSocketClient discord, EntryModel entry)
@@ -36,7 +37,7 @@ public class SocketMemberRoleAuditLogData : ISocketAuditLogData
return user is not null ? RestUser.Create(discord, user) : null;
});
return new SocketMemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), cacheableUser);
return new SocketMemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), cacheableUser, entry.Options?.IntegrationType);
}
/// <summary>
@@ -55,4 +56,9 @@ public class SocketMemberRoleAuditLogData : ISocketAuditLogData
/// A cacheable user object representing the user that the role changes were performed on.
/// </returns>
public Cacheable<SocketUser, RestUser, IUser, ulong> Target { get; }
/// <summary>
/// Gets the type of integration which performed the action. <see langword="null"/> if the action was performed by a user.
/// </summary>
public string IntegrationType { get; }
}