D++ (DPP)
C++ Discord API Bot Library
dpp::permission Class Reference

Represents a permission bitmask (refer to enum dpp::permissions) which are held in an uint64_t. More...

#include <permissions.h>

+ Collaboration diagram for dpp::permission:

Public Member Functions

constexpr permission ()=default
 Default constructor, initializes permission to 0. More...
 
constexpr permission (uint64_t value) noexcept
 Bitmask constructor, initializes permission to the argument. More...
 
constexpr operator uint64_t () const noexcept
 For acting like an integer. More...
 
constexpr operator uint64_t & () noexcept
 For acting like an integer. More...
 
template<typename... T>
constexpr bool can (T... values) const noexcept
 Check for certain permissions, taking into account administrator privileges. It uses the Bitwise AND operator. More...
 
template<typename... T>
constexpr bool can_any (T... values) const noexcept
 Check for certain permissions, taking into account administrator privileges. It uses the Bitwise AND operator. More...
 
template<typename... T>
constexpr bool has (T... values) const noexcept
 Check for permission flags set. It uses the Bitwise AND operator. More...
 
template<typename... T>
constexpr bool has_any (T... values) const noexcept
 Check for permission flags set. It uses the Bitwise AND operator. More...
 
template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > add (T... values) noexcept
 Add a permission with the Bitwise OR operation. More...
 
template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > set (T... values) noexcept
 Assign permissions. This will reset the bitmask to the new value. More...
 
template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > remove (T... values) noexcept
 Remove a permission with the Bitwise NOT operation. More...
 

Protected Attributes

uint64_t value {0}
 The permission bitmask value. More...
 

Detailed Description

Represents a permission bitmask (refer to enum dpp::permissions) which are held in an uint64_t.

Constructor & Destructor Documentation

◆ permission() [1/2]

constexpr dpp::permission::permission ( )
constexprdefault

Default constructor, initializes permission to 0.

◆ permission() [2/2]

constexpr dpp::permission::permission ( uint64_t  value)
inlineconstexprnoexcept

Bitmask constructor, initializes permission to the argument.

Parameters
valueThe bitmask to initialize the permission to

Member Function Documentation

◆ add()

template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > dpp::permission::add ( T...  values)
inlineconstexprnoexcept

Add a permission with the Bitwise OR operation.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to add

Example:

// Adds p_view_channel and p_send_messages to the permission bitmask
constexpr permission()=default
Default constructor, initializes permission to 0.
@ p_view_channel
Allows guild members to view a channel, which includes reading messages in text channels and joining ...
Definition: permissions.h:87
@ p_send_messages
Allows for sending messages in a channel.
Definition: permissions.h:92
Returns
permission& reference to self for chaining

◆ can()

template<typename... T>
constexpr bool dpp::permission::can ( T...  values) const
inlineconstexprnoexcept

Check for certain permissions, taking into account administrator privileges. It uses the Bitwise AND operator.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to check for

Example:

// Returns true if it has permission to p_kick_members and p_ban_members
@ p_ban_members
Allows banning members.
Definition: permissions.h:46
@ p_kick_members
Allows kicking members.
Definition: permissions.h:41
Returns
bool True if it has all the given permissions or dpp::p_administrator

◆ can_any()

template<typename... T>
constexpr bool dpp::permission::can_any ( T...  values) const
inlineconstexprnoexcept

Check for certain permissions, taking into account administrator privileges. It uses the Bitwise AND operator.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to check for

Example:

// Returns true if it has permission to p_kick_members or p_ban_members
Returns
bool True if it has any of the given permissions or dpp::p_administrator

◆ has()

template<typename... T>
constexpr bool dpp::permission::has ( T...  values) const
inlineconstexprnoexcept

Check for permission flags set. It uses the Bitwise AND operator.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to check for

Example:

// Returns true if the permission bitmask contains p_kick_members and p_ban_members
Returns
bool True if it has all the given permissions

◆ has_any()

template<typename... T>
constexpr bool dpp::permission::has_any ( T...  values) const
inlineconstexprnoexcept

Check for permission flags set. It uses the Bitwise AND operator.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to check for

Example:

// Returns true if the permission bitmask contains p_administrator or p_ban_members
@ p_administrator
Allows all permissions and bypasses channel permission overwrites.
Definition: permissions.h:51
Returns
bool True if it has any of the given permissions

◆ operator uint64_t()

constexpr dpp::permission::operator uint64_t ( ) const
inlineconstexprnoexcept

For acting like an integer.

Returns
The permission bitmask value

◆ operator uint64_t &()

constexpr dpp::permission::operator uint64_t & ( )
inlineconstexprnoexcept

For acting like an integer.

Returns
A reference to the permission bitmask value

◆ remove()

template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > dpp::permission::remove ( T...  values)
inlineconstexprnoexcept

Remove a permission with the Bitwise NOT operation.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to remove

Example:

// Removes p_view_channel and p_send_messages permission
Returns
permission& reference to self for chaining

◆ set()

template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > dpp::permission::set ( T...  values)
inlineconstexprnoexcept

Assign permissions. This will reset the bitmask to the new value.

Template Parameters
Tone or more uint64_t permission bits
Parameters
valuesThe permissions (from dpp::permissions) to set

Example:

Returns
permission& reference to self for chaining

Member Data Documentation

◆ value

uint64_t dpp::permission::value {0}
protected

The permission bitmask value.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0