Skip to content

Commit

Permalink
Update DiscordAuditLogChangeObject.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Oct 17, 2023
1 parent 22199ab commit 4129193
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions DisCatSharp/Entities/Guild/AuditLog/DiscordAuditLogChangeObject.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;

using Newtonsoft.Json;

namespace DisCatSharp.Entities.Guild.AuditLog;
Expand All @@ -11,17 +13,56 @@ public class DiscordAuditLogChangeObject
/// Gets the new value of the change.
/// </summary>
[JsonProperty("new_value", NullValueHandling = NullValueHandling.Ignore)]
public object NewValue { get; internal set; }
public object? NewValue { get; internal set; }

/// <summary>
/// Gets the old value of the change.
/// </summary>
[JsonProperty("old_value", NullValueHandling = NullValueHandling.Ignore)]
public object OldValue { get; internal set; }
public object? OldValue { get; internal set; }

/// <summary>
/// Gets the key of the changed entity.
/// </summary>
[JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)]
public string Key { get; internal set; }

[JsonIgnore]
public bool IsSpecialKey
=> SpecialChangeKeys.SpecialKeys.Contains(this.Key);
}

/// <summary>
/// Represents special change keys for the <see cref="DiscordAuditLogChangeObject"/>.
/// </summary>
public static class SpecialChangeKeys
{
/// <summary>
/// Special <see cref="DiscordAuditLogChangeObject.Key"/> for role add.
/// Contains a partial role object.
/// </summary>
public const string PARTIAL_ROLE_ADD = "$add";

/// <summary>
/// Special <see cref="DiscordAuditLogChangeObject.Key"/> for role remove.
/// Contains a partial role object.
/// </summary>
public const string PARTIAL_ROLE_REMOVE = "$remove";

/// <summary>
/// Special <see cref="DiscordAuditLogChangeObject.Key"/> for invite and invite metadata channel ids.
/// Uses <c>channel_id</c> instead of <c>channel</c>.<c>id</c>.
/// </summary>
public const string INVITE_CHANNEL_ID = "channel_id";

/// <summary>
/// Special <see cref="DiscordAuditLogChangeObject.Key"/> for webhook avatars.
/// Uses <c>avatar_hash</c> instead of <c>avatar</c>.
/// </summary>
public const string WEBHOOK_AVATAR = "avatar_hash";

public static readonly List<string> SpecialKeys = new()
{
PARTIAL_ROLE_ADD, PARTIAL_ROLE_REMOVE, INVITE_CHANNEL_ID, WEBHOOK_AVATAR
};
}

0 comments on commit 4129193

Please sign in to comment.