[Fix] NRE in automod audit logs (#2850)

* fix nre

* no breakings :(
This commit is contained in:
Mihail Gribkov
2024-02-15 20:29:33 +03:00
committed by GitHub
parent 61ba44cdce
commit 1eb7a53f78
2 changed files with 9 additions and 9 deletions

View File

@@ -8,23 +8,23 @@ namespace Discord.Rest;
/// </summary> /// </summary>
public class AutoModFlaggedMessageAuditLogData : IAuditLogData public class AutoModFlaggedMessageAuditLogData : IAuditLogData
{ {
internal AutoModFlaggedMessageAuditLogData(ulong channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType) internal AutoModFlaggedMessageAuditLogData(ulong? channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType)
{ {
ChannelId = channelId; ChannelId = channelId ?? 0;
AutoModRuleName = autoModRuleName; AutoModRuleName = autoModRuleName;
AutoModRuleTriggerType = autoModRuleTriggerType; AutoModRuleTriggerType = autoModRuleTriggerType;
} }
internal static AutoModFlaggedMessageAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log) internal static AutoModFlaggedMessageAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
{ {
return new(entry.Options.ChannelId!.Value, entry.Options.AutoModRuleName, return new(entry.Options.ChannelId, entry.Options.AutoModRuleName,
entry.Options.AutoModRuleTriggerType!.Value); entry.Options.AutoModRuleTriggerType!.Value);
} }
/// <summary> /// <summary>
/// Gets the channel the message was sent in. /// Gets the channel the message was sent in. Will be 0 if a user profile was flagged.
/// </summary> /// </summary>
public ulong ChannelId { get; set; } public ulong? ChannelId { get; set; }
/// <summary> /// <summary>
/// Gets the name of the auto moderation rule that got triggered. /// Gets the name of the auto moderation rule that got triggered.

View File

@@ -7,21 +7,21 @@ namespace Discord.WebSocket;
/// </summary> /// </summary>
public class SocketAutoModFlaggedMessageAuditLogData : ISocketAuditLogData public class SocketAutoModFlaggedMessageAuditLogData : ISocketAuditLogData
{ {
internal SocketAutoModFlaggedMessageAuditLogData(ulong channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType) internal SocketAutoModFlaggedMessageAuditLogData(ulong? channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType)
{ {
ChannelId = channelId; ChannelId = channelId ?? 0;
AutoModRuleName = autoModRuleName; AutoModRuleName = autoModRuleName;
AutoModRuleTriggerType = autoModRuleTriggerType; AutoModRuleTriggerType = autoModRuleTriggerType;
} }
internal static SocketAutoModFlaggedMessageAuditLogData Create(DiscordSocketClient discord, EntryModel entry) internal static SocketAutoModFlaggedMessageAuditLogData Create(DiscordSocketClient discord, EntryModel entry)
{ {
return new(entry.Options.ChannelId!.Value, entry.Options.AutoModRuleName, return new(entry.Options.ChannelId, entry.Options.AutoModRuleName,
entry.Options.AutoModRuleTriggerType!.Value); entry.Options.AutoModRuleTriggerType!.Value);
} }
/// <summary> /// <summary>
/// Gets the channel the message was sent in. /// Gets the channel the message was sent in. Will be 0 if a user profile was flagged.
/// </summary> /// </summary>
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }