| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
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:
[legend]

## Public Member Functions

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

## Protected Attributes

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

## Detailed Description

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

## Constructor & Destructor Documentation

## ◆ permission() [1/2]

dpp::permission::permission | ( |  | ) |

constexpr default

Default constructor, initializes permission to 0.

## ◆ permission() [2/2]

dpp::permission::permission | ( | uint64_t | value | ) |

inline constexpr noexcept

Bitmask constructor, initializes permission to the argument.

Parameters

  value | The bitmask to initialize the permission to

## Member Function Documentation

## ◆ add()

template<typename... T>

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

inline constexpr noexcept

Add a permission with the Bitwise OR operation.

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to add

Example:

permission.add(dpp::p_view_channel, dpp::p_send_messages);
// Adds p_view_channel and p_send_messages to the permission bitmask
dpp::permission::permission
constexpr permission()=default
Default constructor, initializes permission to 0.
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:87
dpp::p_send_messages
@ 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>

bool dpp::permission::can | ( | T... | values | ) | const

inline constexpr noexcept

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

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to check for

Example:

bool is_mod = permission.can(dpp::p_kick_members, dpp::p_ban_members);
// Returns true if it has permission to p_kick_members and p_ban_members
dpp::p_ban_members
@ p_ban_members
Allows banning members.
Definition permissions.h:46
dpp::p_kick_members
@ 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>

bool dpp::permission::can_any | ( | T... | values | ) | const

inline constexpr noexcept

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

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to check for

Example:

bool is_mod = permission.can_any(dpp::p_kick_members, dpp::p_ban_members);
// 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>

bool dpp::permission::has | ( | T... | values | ) | const

inline constexpr noexcept

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

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to check for

Example:

bool is_mod = permission.has(dpp::p_kick_members, dpp::p_ban_members);
// 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>

bool dpp::permission::has_any | ( | T... | values | ) | const

inline constexpr noexcept

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

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to check for

Example:

bool is_mod = permission.has_any(dpp::p_administrator, dpp::p_ban_members);
// Returns true if the permission bitmask contains p_administrator or p_ban_members
dpp::p_administrator
@ 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()

dpp::permission::operator uint64_t | ( |  | ) | const

inline constexpr noexcept

For acting like an integer.

Returns
  The permission bitmask value

## ◆ operator uint64_t &()

dpp::permission::operator uint64_t & | ( |  | ) |

inline constexpr noexcept

For acting like an integer.

Returns
  A reference to the permission bitmask value

## ◆ remove()

template<typename... T>

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

inline constexpr noexcept

Remove a permission with the Bitwise NOT operation.

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to remove

Example:

permission.remove(dpp::p_view_channel, dpp::p_send_messages);
// Removes p_view_channel and p_send_messages permission

Returns
  permission& reference to self for chaining

## ◆ set()

template<typename... T>

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

inline constexpr noexcept

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

Template Parameters

  T | one or more uint64_t permission bits

Parameters

  values | The permissions (from dpp::permissions) to set

Example:

permission.set(dpp::p_view_channel, dpp::p_send_messages);

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 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0