Skip to content

Commit

Permalink
Added AllowedMentions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jodenee committed Oct 22, 2024
1 parent 3c72782 commit ef78281
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Sharphook/AllowedMentions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Sharphook.ResponseObjects;
using Sharphook.Utility.Enums;

namespace Sharphook;

public class AllowedMentions
{
public AllowedMentionType? AllowedTypes;
public List<ulong> AllowedRoleMentions = new List<ulong>();
public List<ulong> AllowedUserMentions = new List<ulong>();

public static AllowedMentions All => new AllowedMentions(
AllowedMentionType.Everyone | AllowedMentionType.Roles | AllowedMentionType.Users);

public static AllowedMentions None => new AllowedMentions();

public AllowedMentions(AllowedMentionType? allowedTypes = null)
{
AllowedTypes = allowedTypes;
}

internal AllowedMentionsObject ToAllowedMentionsObject()
{
AllowedMentionsObject allowedMentionsObject = new AllowedMentionsObject();
allowedMentionsObject.Parse = new List<string>();

if ((AllowedTypes & AllowedMentionType.Everyone) == AllowedMentionType.Everyone)
allowedMentionsObject.Parse.Add("everyone");

if ((AllowedTypes & AllowedMentionType.Roles) == AllowedMentionType.Roles)
allowedMentionsObject.Parse.Add("roles");
else
allowedMentionsObject.Roles = AllowedRoleMentions.ToArray();

if ((AllowedTypes & AllowedMentionType.Users) == AllowedMentionType.Users)
allowedMentionsObject.Parse.Add("users");
else
allowedMentionsObject.Users = AllowedUserMentions.ToArray();

return allowedMentionsObject;
}
}

0 comments on commit ef78281

Please sign in to comment.