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

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

#include <permissions.h>

+ Collaboration diagram for dpp::permission:

Public Member Functions

 permission (const uint64_t &value)
 Construct a permission object. More...
 
 permission ()
 Construct a permission object. More...
 
 operator uint64_t () const
 For acting like an integer. More...
 
 operator uint64_t & ()
 For acting like an integer. More...
 
template<typename... T>
bool has (T... values) const
 Check for permission flags set. It uses the Bitwise AND operator. More...
 
template<typename... T>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type add (T... values)
 Add a permission with the Bitwise OR operation. More...
 
template<typename... T>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type set (T... values)
 Assign a permission. This will reset the bitmask to the new value. More...
 
template<typename... T>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type remove (T... values)
 Remove a permission with the Bitwise NOT operation. More...
 

Protected Attributes

uint64_t value
 The permission bitmask value. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ permission() [1/2]

dpp::permission::permission ( const uint64_t &  value)

Construct a permission object.

Parameters
valueA permission bitmask

◆ permission() [2/2]

dpp::permission::permission ( )

Construct a permission object.

Member Function Documentation

◆ add()

template<typename... T>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type dpp::permission::add ( T...  values)
inline

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
permission()
Construct a permission object.
@ p_view_channel
allows guild members to view a channel, which includes reading messages in text channels and joining ...
Definition: permissions.h:43
@ p_send_messages
allows for sending messages in a channel
Definition: permissions.h:44
Returns
permission& reference to self for chaining

◆ has()

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

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
@ p_ban_members
allows banning members
Definition: permissions.h:35
@ p_kick_members
allows kicking members
Definition: permissions.h:34
Returns
bool True if it has all the given permissions

◆ operator uint64_t()

dpp::permission::operator uint64_t ( ) const

For acting like an integer.

Returns
The permission bitmask value

◆ operator uint64_t &()

dpp::permission::operator uint64_t & ( )

For acting like an integer.

Returns
A reference to the permission bitmask value

◆ remove()

template<typename... T>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type dpp::permission::remove ( T...  values)
inline

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>
std::enable_if<(std::is_convertible< T, uint64_t >::value &&...), permission & >::type dpp::permission::set ( T...  values)
inline

Assign a permission. 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
protected

The permission bitmask value.

D++ 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