|
|
@@ -1,4 +1,4 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
|
|
|
|
namespace Discord |
|
|
@@ -6,78 +6,78 @@ namespace Discord |
|
|
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] |
|
|
|
public struct GuildPermissions |
|
|
|
{ |
|
|
|
/// <summary> Gets a blank GuildPermissions that grants no permissions. </summary> |
|
|
|
/// <summary> Gets a blank <see cref="GuildPermissions"/> that grants no permissions. </summary> |
|
|
|
public static readonly GuildPermissions None = new GuildPermissions(); |
|
|
|
/// <summary> Gets a GuildPermissions that grants all guild permissions for webhook users. </summary> |
|
|
|
/// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions for webhook users. </summary> |
|
|
|
public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); |
|
|
|
/// <summary> Gets a GuildPermissions that grants all guild permissions. </summary> |
|
|
|
/// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions. </summary> |
|
|
|
public static readonly GuildPermissions All = new GuildPermissions(0b11111_1111110_1111111110011_111111); |
|
|
|
|
|
|
|
/// <summary> Gets a packed value representing all the permissions in this GuildPermissions. </summary> |
|
|
|
/// <summary> Gets a packed value representing all the permissions in this <see cref="GuildPermissions"/>. </summary> |
|
|
|
public ulong RawValue { get; } |
|
|
|
|
|
|
|
/// <summary> If True, a user may create invites. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may create invites. </summary> |
|
|
|
public bool CreateInstantInvite => Permissions.GetValue(RawValue, GuildPermission.CreateInstantInvite); |
|
|
|
/// <summary> If True, a user may ban users from the guild. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may ban users from the guild. </summary> |
|
|
|
public bool BanMembers => Permissions.GetValue(RawValue, GuildPermission.BanMembers); |
|
|
|
/// <summary> If True, a user may kick users from the guild. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may kick users from the guild. </summary> |
|
|
|
public bool KickMembers => Permissions.GetValue(RawValue, GuildPermission.KickMembers); |
|
|
|
/// <summary> If True, a user is granted all permissions, and cannot have them revoked via channel permissions. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user is granted all permissions, and cannot have them revoked via channel permissions. </summary> |
|
|
|
public bool Administrator => Permissions.GetValue(RawValue, GuildPermission.Administrator); |
|
|
|
/// <summary> If True, a user may create, delete and modify channels. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may create, delete and modify channels. </summary> |
|
|
|
public bool ManageChannels => Permissions.GetValue(RawValue, GuildPermission.ManageChannels); |
|
|
|
/// <summary> If True, a user may adjust guild properties. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may adjust guild properties. </summary> |
|
|
|
public bool ManageGuild => Permissions.GetValue(RawValue, GuildPermission.ManageGuild); |
|
|
|
|
|
|
|
/// <summary> If true, a user may add reactions. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may add reactions. </summary> |
|
|
|
public bool AddReactions => Permissions.GetValue(RawValue, GuildPermission.AddReactions); |
|
|
|
/// <summary> If true, a user may view the audit log. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may view the audit log. </summary> |
|
|
|
public bool ViewAuditLog => Permissions.GetValue(RawValue, GuildPermission.ViewAuditLog); |
|
|
|
|
|
|
|
/// <summary> If True, a user may join channels. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may join channels. </summary> |
|
|
|
public bool ReadMessages => Permissions.GetValue(RawValue, GuildPermission.ReadMessages); |
|
|
|
/// <summary> If True, a user may send messages. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may send messages. </summary> |
|
|
|
public bool SendMessages => Permissions.GetValue(RawValue, GuildPermission.SendMessages); |
|
|
|
/// <summary> If True, a user may send text-to-speech messages. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may send text-to-speech messages. </summary> |
|
|
|
public bool SendTTSMessages => Permissions.GetValue(RawValue, GuildPermission.SendTTSMessages); |
|
|
|
/// <summary> If True, a user may delete messages. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may delete messages. </summary> |
|
|
|
public bool ManageMessages => Permissions.GetValue(RawValue, GuildPermission.ManageMessages); |
|
|
|
/// <summary> If True, Discord will auto-embed links sent by this user. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, Discord will auto-embed links sent by this user. </summary> |
|
|
|
public bool EmbedLinks => Permissions.GetValue(RawValue, GuildPermission.EmbedLinks); |
|
|
|
/// <summary> If True, a user may send files. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may send files. </summary> |
|
|
|
public bool AttachFiles => Permissions.GetValue(RawValue, GuildPermission.AttachFiles); |
|
|
|
/// <summary> If True, a user may read previous messages. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may read previous messages. </summary> |
|
|
|
public bool ReadMessageHistory => Permissions.GetValue(RawValue, GuildPermission.ReadMessageHistory); |
|
|
|
/// <summary> If True, a user may mention @everyone. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may mention @everyone. </summary> |
|
|
|
public bool MentionEveryone => Permissions.GetValue(RawValue, GuildPermission.MentionEveryone); |
|
|
|
/// <summary> If True, a user may use custom emoji from other guilds. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may use custom emoji from other guilds. </summary> |
|
|
|
public bool UseExternalEmojis => Permissions.GetValue(RawValue, GuildPermission.UseExternalEmojis); |
|
|
|
|
|
|
|
/// <summary> If True, a user may connect to a voice channel. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may connect to a voice channel. </summary> |
|
|
|
public bool Connect => Permissions.GetValue(RawValue, GuildPermission.Connect); |
|
|
|
/// <summary> If True, a user may speak in a voice channel. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may speak in a voice channel. </summary> |
|
|
|
public bool Speak => Permissions.GetValue(RawValue, GuildPermission.Speak); |
|
|
|
/// <summary> If True, a user may mute users. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may mute users. </summary> |
|
|
|
public bool MuteMembers => Permissions.GetValue(RawValue, GuildPermission.MuteMembers); |
|
|
|
/// <summary> If True, a user may deafen users. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may deafen users. </summary> |
|
|
|
public bool DeafenMembers => Permissions.GetValue(RawValue, GuildPermission.DeafenMembers); |
|
|
|
/// <summary> If True, a user may move other users between voice channels. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may move other users between voice channels. </summary> |
|
|
|
public bool MoveMembers => Permissions.GetValue(RawValue, GuildPermission.MoveMembers); |
|
|
|
/// <summary> If True, a user may use voice-activity-detection rather than push-to-talk. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may use voice-activity-detection rather than push-to-talk. </summary> |
|
|
|
public bool UseVAD => Permissions.GetValue(RawValue, GuildPermission.UseVAD); |
|
|
|
|
|
|
|
/// <summary> If True, a user may change their own nickname. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may change their own nickname. </summary> |
|
|
|
public bool ChangeNickname => Permissions.GetValue(RawValue, GuildPermission.ChangeNickname); |
|
|
|
/// <summary> If True, a user may change the nickname of other users. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may change the nickname of other users. </summary> |
|
|
|
public bool ManageNicknames => Permissions.GetValue(RawValue, GuildPermission.ManageNicknames); |
|
|
|
/// <summary> If True, a user may adjust roles. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may adjust roles. </summary> |
|
|
|
public bool ManageRoles => Permissions.GetValue(RawValue, GuildPermission.ManageRoles); |
|
|
|
/// <summary> If True, a user may edit the webhooks for this guild. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may edit the webhooks for this guild. </summary> |
|
|
|
public bool ManageWebhooks => Permissions.GetValue(RawValue, GuildPermission.ManageWebhooks); |
|
|
|
/// <summary> If True, a user may edit the emojis for this guild. </summary> |
|
|
|
/// <summary> If <see langword="true"/>, a user may edit the emojis for this guild. </summary> |
|
|
|
public bool ManageEmojis => Permissions.GetValue(RawValue, GuildPermission.ManageEmojis); |
|
|
|
|
|
|
|
/// <summary> Creates a new GuildPermissions with the provided packed value. </summary> |
|
|
|
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary> |
|
|
|
public GuildPermissions(ulong rawValue) { RawValue = rawValue; } |
|
|
|
|
|
|
|
private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, bool? kickMembers = null, |
|
|
@@ -123,7 +123,7 @@ namespace Discord |
|
|
|
RawValue = value; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> Creates a new GuildPermissions with the provided permissions. </summary> |
|
|
|
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided permissions. </summary> |
|
|
|
public GuildPermissions(bool createInstantInvite = false, bool kickMembers = false, |
|
|
|
bool banMembers = false, bool administrator = false, bool manageChannels = false, bool manageGuild = false, |
|
|
|
bool addReactions = false, bool viewAuditLog = false, |
|
|
@@ -141,7 +141,7 @@ namespace Discord |
|
|
|
manageNicknames: manageNicknames, manageWebhooks: manageWebhooks, manageEmojis: manageEmojis) |
|
|
|
{ } |
|
|
|
|
|
|
|
/// <summary> Creates a new GuildPermissions from this one, changing the provided non-null permissions. </summary> |
|
|
|
/// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary> |
|
|
|
public GuildPermissions Modify(bool? createInstantInvite = null, bool? kickMembers = null, |
|
|
|
bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null, |
|
|
|
bool? addReactions = null, bool? viewAuditLog = null, |
|
|
|