/// <summary> /// Sets a specified permission on a user. /// </summary> /// <param name="permission"></param> public void SetPermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) { return; } raw |= (uint)(1 << (byte)permission); }
/// <summary> /// Checks to see if the role has a specific permission. /// </summary> /// <param name="permission"></param> /// <returns>True or false.</returns> public bool HasPermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) { return(false); } return(((raw >> (byte)permission) & 1) != 0); }
/// <summary> /// Removes the specified permission on a user. /// </summary> /// <param name="permission"></param> public void RemovePermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) { return; } raw &= (uint)~(1 << (byte)permission); }
/// <summary> /// Iterates all the roles the user has checking if any of the present have the permission you pass. /// </summary> /// <param name="permission">The permission to check.</param> /// <returns>True if the permission is present.</returns> public bool HasPermission(DiscordSpecialPermissions permission) { var result = false; Roles.ForEach(x => { if (x.Permissions.HasPermission(permission)) { result = true; return; } }); return(result); }
/// <summary> /// Removes the specified permission on a user. /// </summary> /// <param name="permission"></param> public void RemovePermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) return; raw &= (uint)~(1 << (byte)permission); }
/// <summary> /// Sets a specified permission on a user. /// </summary> /// <param name="permission"></param> public void SetPermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) return; raw |= (uint)(1 << (byte)permission); }
/// <summary> /// Checks to see if the role has a specific permission. /// </summary> /// <param name="permission"></param> /// <returns>True or false.</returns> public bool HasPermission(DiscordSpecialPermissions permission) { if (permission == DiscordSpecialPermissions.None) return false; return ((raw >> (byte)permission)&1) != 0; }
/// <summary> /// Iterates all the roles the user has checking if any of the present have the permission you pass. /// </summary> /// <param name="permission">The permission to check.</param> /// <returns>True if the permission is present.</returns> public bool HasPermission(DiscordSpecialPermissions permission) { var result = false; Roles.ForEach(x => { if (x.Permissions.HasPermission(permission)) { result = true; return; } }); return result; }