Skip to content

Commit

Permalink
aaaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Oct 17, 2023
1 parent b609d34 commit ae98534
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
namespace DisCatSharp.Entities;
using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for the creation of a creator monetization request.
/// </summary>
public class CreatorMonetizationRequestCreatedChangeSet : DiscordAuditLogEntry
{ }
{
public CreatorMonetizationRequestCreatedChangeSet()
{
this.ValidFor = AuditLogActionType.CreatorMonetizationRequestCreated;
}

/// <inheritdoc />
internal override string? ChangeDescription
=> $"{this.UserId} created Creator Monetization Request";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
namespace DisCatSharp.Entities;
using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for the acceptance of creator monetization terms.
/// </summary>
public class CreatorMonetizationTermsAcceptedChangeSet : DiscordAuditLogEntry
{ }
{
public CreatorMonetizationTermsAcceptedChangeSet()
{
this.ValidFor = AuditLogActionType.CreatorMonetizationTermsAccepted;
}

/// <inheritdoc />
internal override string? ChangeDescription
=> $"{this.UserId} accepted Creator Monetization Terms";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
namespace DisCatSharp.Entities;
using System.Collections.Generic;
using System.Linq;

using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for creating an emoji.
/// </summary>
public class EmojiCreateChangeSet : DiscordAuditLogEntry
{ }
{
public EmojiCreateChangeSet()
{
this.ValidFor = AuditLogActionType.EmojiCreate;
}

public string? EmojiName => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.NewValue;
public IReadOnlyList<ulong>? RolesAllowed => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public bool EmojiNameChanged => this.EmojiName is not null;
public bool RolesAllowedChanged => this.RolesAllowed is not null;

/// <inheritdoc />
internal override string ChangeDescription
{
get
{
var description = $"{this.UserId} created a new emoji with the following details:\n";
if (this.EmojiNameChanged)
description += $"- Emoji Name: {this.EmojiName}\n";
if (this.RolesAllowedChanged)
description += $"- Roles Allowed: {string.Join(", ", this.RolesAllowed)}\n";
return description;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
namespace DisCatSharp.Entities;
using System.Collections.Generic;
using System.Linq;

using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for deleting an emoji.
/// </summary>
public class EmojiDeleteChangeSet : DiscordAuditLogEntry
{ }
{
public EmojiDeleteChangeSet()
{
this.ValidFor = AuditLogActionType.EmojiDelete;
}

public string? EmojiName => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.OldValue;
public IReadOnlyList<ulong>? RolesAllowed => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.OldValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public bool EmojiNameChanged => this.EmojiName is not null;
public bool RolesAllowedChanged => this.RolesAllowed is not null;

/// <inheritdoc />
internal override string ChangeDescription
{
get
{
var description = $"{this.UserId} deleted emoji {this.TargetId}:\n";
if (this.EmojiNameChanged)
description += $"- Name: {this.EmojiName}\n";
if (this.RolesAllowedChanged)
description += $"- Roles Allowed: {string.Join(", ", this.RolesAllowed)}\n";
return description;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
namespace DisCatSharp.Entities;
using System.Collections.Generic;
using System.Linq;

using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for updating the name of an emoji.
/// </summary>
public class EmojiUpdateChangeSet : DiscordAuditLogEntry
{ }
{
public EmojiUpdateChangeSet()
{
this.ValidFor = AuditLogActionType.EmojiUpdate;
}

public string? EmojiNameBefore => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.OldValue;
public string? EmojiNameAfter => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.NewValue;
public IReadOnlyList<ulong>? RolesAllowedBefore => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.OldValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public IReadOnlyList<ulong>? RolesAllowedAfter => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public bool EmojiNameChanged => this.EmojiNameBefore is not null || this.EmojiNameAfter is not null;
public bool RolesAllowedChanged => this.RolesAllowedBefore is not null || this.RolesAllowedAfter is not null;

/// <inheritdoc />
internal override string ChangeDescription
{
get
{
var description = $"{this.UserId} updated emoji {this.TargetId}:\n";
if (this.EmojiNameChanged)
{
description += this.EmojiNameBefore is not null ? $"- Emoji Name Before: {this.EmojiNameBefore}\n" : "- Emoji Name Before: Not set\n";
description += this.EmojiNameAfter is not null ? $"- Emoji Name After: {this.EmojiNameAfter}\n" : "- Emoji Name After: Not set\n";
}

if (this.RolesAllowedChanged)
{
description += this.RolesAllowedBefore is not null ? $"- Roles Before: {string.Join(", ", this.RolesAllowedBefore)}\n" : "- Roles Before: Not set\n";
description += this.RolesAllowedAfter is not null ? $"- Roles After: {string.Join(", ", this.RolesAllowedAfter)}\n" : "- Roles After: Not set\n";
}

return description;
}
}
}

0 comments on commit ae98534

Please sign in to comment.