D++ (DPP)  10.0.30
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...
 
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 bool can (T... values) const noexcept
 Check for certain permissions, taking into account administrator privileges. More...
 
template<typename... T>
constexpr bool can_any (T... values) const noexcept
 Check for certain permissions, taking into account administrator privileges. More...
 
template<typename... T>
constexpr bool has (T... values) const noexcept
 Check for permission flags set. More...
 
template<typename... T>
constexpr bool has_any (T... values) const noexcept
 Check for permission flags set. 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 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...
 
template<typename... T>
constexpr std::enable_if_t<(std::is_convertible_v< T, uint64_t > &&...), permission & > set (T... values) noexcept
 Assign permissions. 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
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
Returns
bool True if it has all the given permissions or dpp::p_administrator

References 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
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.


The documentation for this class was generated from the following files:
dpp::permission::permission
constexpr permission()=default
Default constructor, initializes permission to 0.
dpp::p_administrator
@ p_administrator
Allows all permissions and bypasses channel permission overwrites.
Definition: permissions.h:89
dpp::p_kick_members
@ p_kick_members
Allows kicking members.
Definition: permissions.h:79
dpp::p_send_messages
@ p_send_messages
Allows for sending messages in a channel.
Definition: permissions.h:130
dpp::p_view_channel
@ p_view_channel
Allows guild members to view a channel, which includes reading messages in text channels and joining ...
Definition: permissions.h:125
dpp::p_ban_members
@ p_ban_members
Allows banning members.
Definition: permissions.h:84