Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <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;
 }
Ejemplo n.º 8
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;
        }