[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:
@@ -39,4 +39,7 @@ internal class AuditLogOptions
|
|||||||
|
|
||||||
[JsonProperty("status")]
|
[JsonProperty("status")]
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("integration_type")]
|
||||||
|
public string IntegrationType { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,16 @@ namespace Discord.Rest;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class KickAuditLogData : IAuditLogData
|
public class KickAuditLogData : IAuditLogData
|
||||||
{
|
{
|
||||||
private KickAuditLogData(RestUser user)
|
private KickAuditLogData(RestUser user, string integrationType)
|
||||||
{
|
{
|
||||||
Target = user;
|
Target = user;
|
||||||
|
IntegrationType = integrationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static KickAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
|
internal static KickAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
|
||||||
{
|
{
|
||||||
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
||||||
return new KickAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
|
return new KickAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null, entry.Options?.IntegrationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -30,4 +31,9 @@ public class KickAuditLogData : IAuditLogData
|
|||||||
/// A user object representing the kicked user.
|
/// A user object representing the kicked user.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IUser Target { get; }
|
public IUser 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; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ namespace Discord.Rest;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MemberRoleAuditLogData : IAuditLogData
|
public class MemberRoleAuditLogData : IAuditLogData
|
||||||
{
|
{
|
||||||
private MemberRoleAuditLogData(IReadOnlyCollection<MemberRoleEditInfo> roles, IUser target)
|
private MemberRoleAuditLogData(IReadOnlyCollection<MemberRoleEditInfo> roles, IUser target, string integrationType)
|
||||||
{
|
{
|
||||||
Roles = roles;
|
Roles = roles;
|
||||||
Target = target;
|
Target = target;
|
||||||
|
IntegrationType = integrationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static MemberRoleAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
|
internal static MemberRoleAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
|
||||||
@@ -28,7 +29,7 @@ public class MemberRoleAuditLogData : IAuditLogData
|
|||||||
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
||||||
RestUser user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
|
RestUser user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
|
||||||
|
|
||||||
return new MemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), user);
|
return new MemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), user, entry.Options?.IntegrationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -47,4 +48,9 @@ public class MemberRoleAuditLogData : IAuditLogData
|
|||||||
/// A user object representing the user that the role changes were performed on.
|
/// A user object representing the user that the role changes were performed on.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IUser Target { get; }
|
public IUser 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; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ namespace Discord.WebSocket;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SocketKickAuditLogData : ISocketAuditLogData
|
public class SocketKickAuditLogData : ISocketAuditLogData
|
||||||
{
|
{
|
||||||
private SocketKickAuditLogData(Cacheable<SocketUser, RestUser, IUser, ulong> user)
|
private SocketKickAuditLogData(Cacheable<SocketUser, RestUser, IUser, ulong> user, string integrationType)
|
||||||
{
|
{
|
||||||
Target = user;
|
Target = user;
|
||||||
|
IntegrationType = integrationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SocketKickAuditLogData Create(DiscordSocketClient discord, EntryModel entry)
|
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);
|
var user = await discord.ApiClient.GetUserAsync(entry.TargetId!.Value);
|
||||||
return user is not null ? RestUser.Create(discord, user) : null;
|
return user is not null ? RestUser.Create(discord, user) : null;
|
||||||
});
|
});
|
||||||
return new SocketKickAuditLogData(cacheableUser);
|
return new SocketKickAuditLogData(cacheableUser, entry.Options?.IntegrationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,4 +41,9 @@ public class SocketKickAuditLogData : ISocketAuditLogData
|
|||||||
/// A cacheable user object representing the kicked user.
|
/// A cacheable user object representing the kicked user.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Cacheable<SocketUser, RestUser, IUser, ulong> Target { get; }
|
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; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ namespace Discord.WebSocket;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SocketMemberRoleAuditLogData : ISocketAuditLogData
|
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;
|
Roles = roles;
|
||||||
Target = target;
|
Target = target;
|
||||||
|
IntegrationType = integrationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SocketMemberRoleAuditLogData Create(DiscordSocketClient discord, EntryModel entry)
|
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 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>
|
/// <summary>
|
||||||
@@ -55,4 +56,9 @@ public class SocketMemberRoleAuditLogData : ISocketAuditLogData
|
|||||||
/// A cacheable user object representing the user that the role changes were performed on.
|
/// A cacheable user object representing the user that the role changes were performed on.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Cacheable<SocketUser, RestUser, IUser, ulong> Target { get; }
|
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; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user