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

Search
Loading...
Searching...
No Matches
dpp::guild_member Class Reference

Represents dpp::user membership upon a dpp::guild. This contains the user's nickname, guild roles, and any other guild-specific flags. More...

`#include <guild.h>`

Inheritance diagram for dpp::guild_member:
[legend]
Collaboration diagram for dpp::guild_member:
[legend]

## Public Member Functions

| guild_member ()
guild_member & | add_role (dpp::snowflake role_id)
| Add a role to this member.
std::string | build_json (bool with_id=false) const
| Convert object to json string.
guild_member & | fill_from_json (nlohmann::json *j, snowflake g_id, snowflake u_id)
| Fill this object from a json object.
guild_member & | fill_from_json (nlohmann::json *j)
| Convert object from nlohmann::json.
std::string | get_avatar_url (uint16_t size=0, const image_type format=i_png, bool prefer_animated=true) const
| Returns the member's per guild avatar url if they have one, otherwise returns an empty string.
std::string | get_mention () const
| Return a ping/mention for the user by nickname.
std::string | get_nickname () const
| Get the nickname.
const std::vector< dpp::snowflake > & | get_roles () const
| Get the roles.
user * | get_user () const
| Find the dpp::user object for this member. This is an alias for dpp::find_user.
bool | has_animated_guild_avatar () const
| Returns true if the user's per-guild custom avatar is animated.
bool | has_bypasses_verification () const
| Returns true if the user is exempt from guild verification requirements.
bool | has_completed_onboarding () const
| Returns true if the user has completed onboarding.
bool | has_rejoined () const
| Returns true if the user has left and rejoined the guild.
bool | has_started_onboarding () const
| Returns true if the user has started onboarding.
bool | is_communication_disabled () const
| Returns true if the user is in time-out (communication disabled).
bool | is_deaf () const
| Returns true if the user is deafened.
bool | is_guild_owner () const
| Is this user also the guild member?
bool | is_muted () const
| Returns true if the user is muted.
bool | is_pending () const
| Returns true if pending verification by membership screening.
bool | operator== (guild_member const &other_member) const
| Check if this member is equal to another member object.
guild_member & | remove_role (dpp::snowflake role_id)
| Remove a role from this member.
guild_member & | set_bypasses_verification (const bool is_bypassing_verification)
| Set whether the user is exempt from guild verification requirements.
guild_member & | set_communication_disabled_until (const time_t timestamp)
| Set communication_disabled_until.
guild_member & | set_deaf (const bool is_deafened)
| Set whether the user is deafened in voice channels.
guild_member & | set_mute (const bool is_muted)
| Set whether the user is muted in voice channels.
guild_member & | set_nickname (const std::string &nick)
| Set the nickname.
guild_member & | set_roles (const std::vector< dpp::snowflake > &role_ids)
| Set a new role list for this member.
auto | to_json (bool with_id=false) const
| Convert object to nlohmann::json.

## Public Attributes

utility::iconhash | avatar
| User avatar.
time_t | communication_disabled_until
| Timestamp of when the time out will be removed; until then, they cannot interact with the guild.
snowflake | guild_id
| Guild id.
time_t | joined_at
| Date and time the user joined the guild.
time_t | premium_since
| The Date and time the user started boosting.
snowflake | user_id
| User id.

## Protected Member Functions

json | to_json_impl (bool with_id=false) const
| Build json for the member object.

## Protected Attributes

uint16_t | flags
| A set of flags built from the bitmask defined by dpp::guild_member_flags.
std::string | nickname
| Nickname.
std::vector< snowflake > | roles
| List of roles this user has on this guild.

## Friends

void | from_json (const nlohmann::json &j, guild_member &gm)
| helper function to deserialize a guild_member from json
struct | json_interface< guild_member >

## Detailed Description

Represents dpp::user membership upon a dpp::guild. This contains the user's nickname, guild roles, and any other guild-specific flags.

## Constructor & Destructor Documentation

## ◆ guild_member()

dpp::guild_member::guild_member | ( |  | ) |

Default constructor

## Member Function Documentation

## ◆ add_role()

guild_member & dpp::guild_member::add_role | ( | dpp::snowflake | role_id | ) |

Add a role to this member.

Note
  This call sets the role change bit, which causes the new role list to be sent if this is passed to dpp::cluster::guild_edit_member or dpp::cluster::guild_add_member

Parameters

  role_id | Role ID to add

Returns
  guild_member& Reference to self

## ◆ build_json()

std::string dpp::json_interface< guild_member >::build_json | ( | bool | with_id = false | ) | const

inline inherited

Convert object to json string.

Parameters

  with_id | Whether to include the ID or not

Note
  Some fields are conditionally filled, do not rely on all fields being present

Returns
  std::string Json built from the structure

## ◆ fill_from_json() [1/2]

guild_member & dpp::guild_member::fill_from_json | ( | nlohmann::json * | j,
|  | snowflake | g_id,
|  | snowflake | u_id )

Fill this object from a json object.

Parameters

  j | The json object to get data from
  g_id | The guild id to associate the member with
  u_id | The user id to associate the member with

Returns
  Reference to self for call chaining

## ◆ fill_from_json() [2/2]

guild_member & dpp::json_interface< guild_member >::fill_from_json | ( | nlohmann::json * | j | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::json object

Returns
  T& Reference to self for fluent calling

## ◆ get_avatar_url()

std::string dpp::guild_member::get_avatar_url | ( | uint16_t | size = 0,
|  | const image_type | format = i_png,
|  | bool | prefer_animated = true ) const

Returns the member's per guild avatar url if they have one, otherwise returns an empty string.

Note
  per-server avatar is a nitro only feature so it might be not set. If you need the user avatar, use user::get_avatar_url.

Parameters

  size | The size of the avatar in pixels. It can be any power of two between 16 and 4096, otherwise the default sized avatar is returned.
  format | The format to use for the avatar. It can be one of i_webp, i_jpg, i_png or i_gif. When passing i_gif, it returns an empty string for non-animated images. Consider using the prefer_animated parameter instead.
  prefer_animated | Whether you prefer gif format. If true, it'll return gif format whenever the image is available as animated.

Returns
  std::string avatar url or an empty string, if required attributes are missing or an invalid format was passed

## ◆ get_mention()

std::string dpp::guild_member::get_mention | ( |  | ) | const

Return a ping/mention for the user by nickname.

Returns
  std::string mention

## ◆ get_nickname()

std::string dpp::guild_member::get_nickname | ( |  | ) | const

Get the nickname.

Returns
  std::string nickname

## ◆ get_roles()

const std::vector< dpp::snowflake > & dpp::guild_member::get_roles | ( |  | ) | const

Get the roles.

Returns
  std::vector<dpp::snowflake> roles

## ◆ get_user()

user * dpp::guild_member::get_user | ( |  | ) | const

Find the dpp::user object for this member. This is an alias for dpp::find_user.

Returns
  dpp::user* Pointer to the user object. If not in cache, it returns nullptr

## ◆ has_animated_guild_avatar()

bool dpp::guild_member::has_animated_guild_avatar | ( |  | ) | const

Returns true if the user's per-guild custom avatar is animated.

Returns
  true user's custom avatar is animated
  false user's custom avatar is not animated

## ◆ has_bypasses_verification()

bool dpp::guild_member::has_bypasses_verification | ( |  | ) | const

Returns true if the user is exempt from guild verification requirements.

Returns
  true user bypasses verification
  false user doesn't bypass verification

## ◆ has_completed_onboarding()

bool dpp::guild_member::has_completed_onboarding | ( |  | ) | const

Returns true if the user has completed onboarding.

Returns
  true user has completed onboarding
  false user has not completed onboarding

## ◆ has_rejoined()

bool dpp::guild_member::has_rejoined | ( |  | ) | const

Returns true if the user has left and rejoined the guild.

Returns
  true user has left and rejoined the guild
  false user has not rejoined

## ◆ has_started_onboarding()

bool dpp::guild_member::has_started_onboarding | ( |  | ) | const

Returns true if the user has started onboarding.

Returns
  true user has started onboarding
  false user has not started onboarding yet

## ◆ is_communication_disabled()

bool dpp::guild_member::is_communication_disabled | ( |  | ) | const

Returns true if the user is in time-out (communication disabled).

Returns
  true user is in time-out
  false user is not in time-out

## ◆ is_deaf()

bool dpp::guild_member::is_deaf | ( |  | ) | const

Returns true if the user is deafened.

Returns
  true user is deafened
  false user is not deafened

## ◆ is_guild_owner()

bool dpp::guild_member::is_guild_owner | ( |  | ) | const

Is this user also the guild member?

Returns
  true if the user is the guild owner.
  false if the user is not the guild owner or the guild is not in the cache.

Note
  If the guild cache is disabled, this function will always return false.

## ◆ is_muted()

bool dpp::guild_member::is_muted | ( |  | ) | const

Returns true if the user is muted.

Returns
  true user muted
  false user not muted

## ◆ is_pending()

bool dpp::guild_member::is_pending | ( |  | ) | const

Returns true if pending verification by membership screening.

Returns
  true user has completed membership screening
  false user has not completed membership screening

## ◆ operator==()

bool dpp::guild_member::operator== | ( | guild_member const & | other_member | ) | const

Check if this member is equal to another member object.

Parameters

  other_member | other member object to compare

Returns
  true if their user ids are equal, false otherwise.

## ◆ remove_role()

guild_member & dpp::guild_member::remove_role | ( | dpp::snowflake | role_id | ) |

Remove a role from this member.

Note
  This call sets the role change bit, which causes the new role list to be sent if this is passed to dpp::cluster::guild_edit_member or dpp::cluster::guild_add_member

Parameters

  role_id | Role ID to remove

Returns
  guild_member& Reference to self

## ◆ set_bypasses_verification()

guild_member & dpp::guild_member::set_bypasses_verification | ( | const bool | is_bypassing_verification | ) |

Set whether the user is exempt from guild verification requirements.

Parameters

  is_bypassing_verification | value to set

Returns
  guild_member& reference to self

## ◆ set_communication_disabled_until()

guild_member & dpp::guild_member::set_communication_disabled_until | ( | const time_t | timestamp | ) |

Set communication_disabled_until.

Parameters

  timestamp | timestamp until communication is disabled

Returns
  guild_member& reference to self

## ◆ set_deaf()

guild_member & dpp::guild_member::set_deaf | ( | const bool | is_deafened | ) |

Set whether the user is deafened in voice channels.

Parameters

  is_deafened | value to set, true if deaf in voice channels

Returns
  guild_member& reference to self

## ◆ set_mute()

guild_member & dpp::guild_member::set_mute | ( | const bool | is_muted | ) |

Set whether the user is muted in voice channels.

Parameters

  is_muted | value to set, true if mute in voice channels

Returns
  guild_member& reference to self

## ◆ set_nickname()

guild_member & dpp::guild_member::set_nickname | ( | const std::string & | nick | ) |

Set the nickname.

Parameters

  nick | Nickname to set

Returns
  guild_member& reference to self

## ◆ set_roles()

guild_member & dpp::guild_member::set_roles | ( | const std::vector< dpp::snowflake > & | role_ids | ) |

Set a new role list for this member.

Note
  This call sets the role change bit, which causes the new role list to be sent if this is passed to dpp::cluster::guild_edit_member or dpp::cluster::guild_add_member

Parameters

  role_ids | Roles to set

Returns
  guild_member& Reference to self

## ◆ to_json()

auto dpp::json_interface< guild_member >::to_json | ( | bool | with_id = false | ) | const

inline inherited

Convert object to nlohmann::json.

Parameters

  with_id | Whether to include the ID or not

Note
  Some fields are conditionally filled, do not rely on all fields being present

Returns
  json Json built from the structure

## ◆ to_json_impl()

json dpp::guild_member::to_json_impl | ( | bool | with_id = false | ) | const

protected

Build json for the member object.

Parameters

  with_id | Add ID to output

Returns
  json JSON object

## Friends And Related Symbol Documentation

## ◆ from_json

void from_json | ( | const nlohmann::json & | j,
|  | guild_member & | gm )

friend

helper function to deserialize a guild_member from json

See also
  https://github.com/nlohmann/json#arbitrary-types-conversions

Parameters

  j | output json object
  gm | guild_member to be deserialized

## ◆ json_interface< guild_member >

friend struct json_interface< guild_member >

friend

## Member Data Documentation

## ◆ avatar

utility::iconhash dpp::guild_member::avatar

User avatar.

Note
  Per-server avatar is a nitro only feature.

## ◆ communication_disabled_until

time_t dpp::guild_member::communication_disabled_until

Timestamp of when the time out will be removed; until then, they cannot interact with the guild.

## ◆ flags

uint16_t dpp::guild_member::flags

protected

A set of flags built from the bitmask defined by dpp::guild_member_flags.

## ◆ guild_id

snowflake dpp::guild_member::guild_id

Guild id.

## ◆ joined_at

time_t dpp::guild_member::joined_at

Date and time the user joined the guild.

## ◆ nickname

std::string dpp::guild_member::nickname

protected

Nickname.

Note
  Empty string if they don't have a nickname on this guild

## ◆ premium_since

time_t dpp::guild_member::premium_since

The Date and time the user started boosting.

## ◆ roles

std::vector<snowflake> dpp::guild_member::roles

protected

List of roles this user has on this guild.

## ◆ user_id

snowflake dpp::guild_member::user_id

User id.

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