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

Represents dpp::user membership upon a dpp::guild. More...

#include "guild.h"

Inheritance diagram for dpp::guild_member:
Collaboration diagram for dpp::guild_member:

Public Member Functions

 guild_member ()
 Default constructor. More...
 
guild_memberadd_role (dpp::snowflake role_id)
 Add a role to this member. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 
guild_memberfill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
guild_memberfill_from_json (nlohmann::json *j, snowflake g_id, snowflake u_id)
 Fill this object from a json object. More...
 
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. More...
 
std::string get_mention () const
 Return a ping/mention for the user by nickname. More...
 
std::string get_nickname () const
 Get the nickname. More...
 
const std::vector< dpp::snowflake > & get_roles () const
 Get the roles. More...
 
userget_user () const
 Find the dpp::user object for this member. More...
 
bool has_animated_guild_avatar () const
 Returns true if the user's per-guild custom avatar is animated. More...
 
bool has_bypasses_verification () const
 Returns true if the user is exempt from guild verification requirements. More...
 
bool has_completed_onboarding () const
 Returns true if the user has completed onboarding. More...
 
bool has_rejoined () const
 Returns true if the user has left and rejoined the guild. More...
 
bool has_started_onboarding () const
 Returns true if the user has started onboarding. More...
 
bool is_communication_disabled () const
 Returns true if the user is in time-out (communication disabled) More...
 
bool is_deaf () const
 Returns true if the user is deafened. More...
 
bool is_guild_owner () const
 Is this user also the guild member? More...
 
bool is_muted () const
 Returns true if the user is muted. More...
 
bool is_pending () const
 Returns true if pending verification by membership screening. More...
 
bool operator== (guild_member const &other_member) const
 Check if this member is equal to another member object. More...
 
guild_memberremove_role (dpp::snowflake role_id)
 Remove a role from this member. More...
 
guild_memberset_bypasses_verification (const bool is_bypassing_verification)
 Set whether the user is exempt from guild verification requirements. More...
 
guild_memberset_communication_disabled_until (const time_t timestamp)
 Set communication_disabled_until. More...
 
guild_memberset_deaf (const bool is_deafened)
 Set whether the user is deafened in voice channels. More...
 
guild_memberset_mute (const bool is_muted)
 Set whether the user is muted in voice channels. More...
 
guild_memberset_nickname (const std::string &nick)
 Set the nickname. More...
 
guild_memberset_roles (const std::vector< dpp::snowflake > &role_ids)
 Set a new role list for this member. More...
 
auto to_json (bool with_id=false) const
 Convert object to nlohmann::json. More...
 

Public Attributes

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

Protected Member Functions

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

Protected Attributes

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

Friends

void from_json (const nlohmann::json &j, guild_member &gm)
 helper function to deserialize a guild_member from json More...
 
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.

References flags, dpp::gm_roles_action, and roles.

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_idRole ID to add
Returns
guild_member& Reference to self

References flags, dpp::gm_roles_action, and roles.

◆ build_json()

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

Convert object to json string.

Parameters
with_idWhether 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::json_interface< guild_member >::fill_from_json ( nlohmann::json j)
inlineinherited

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json() [2/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
jThe json object to get data from
g_idThe guild id to associate the member with
u_idThe user id to associate the member with
Returns
Reference to self for call chaining

Referenced by dpp::cluster::guild_get_member().

Here is the caller graph for this function:

◆ 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
sizeThe size of the avatar in pixels. It can be any power of two between 16 and 4096, otherwise the default sized avatar is returned.
formatThe 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_animatedWhether 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

References flags, dpp::gm_mute, dpp::gm_voice_action, and is_muted().

Here is the call graph for this function:

◆ get_roles()

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

Get the roles.

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

Referenced by dpp::guild_widget::to_json_impl().

Here is the caller graph for this function:

◆ 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

References dpp::find_guild(), guild_id, and user_id.

Here is the call graph for this function:

◆ 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

References dpp::welcome_channel::emoji_id.

◆ 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

References dpp::welcome_channel::channel_id.

◆ 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

Referenced by get_nickname().

Here is the caller graph for this function:

◆ 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_memberother 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_idRole 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_verificationvalue 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
timestamptimestamp until communication is disabled
Returns
guild_member& reference to self

References communication_disabled_until.

◆ set_deaf()

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

Set whether the user is deafened in voice channels.

Parameters
is_deafenedvalue 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_mutedvalue 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
nickNickname 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_idsRoles to set
Returns
guild_member& Reference to self

◆ to_json()

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

Convert object to nlohmann::json.

Parameters
with_idWhether 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_idAdd ID to output
Returns
json JSON object

Friends And Related Function 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
joutput json object
gmguild_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.

Referenced by set_communication_disabled_until().

◆ flags

uint16_t dpp::guild_member::flags
protected

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

Referenced by add_role(), get_nickname(), guild_member(), and dpp::guild::remove_icon().

◆ guild_id

snowflake dpp::guild_member::guild_id

Guild id.

Referenced by get_user().

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

Referenced by add_role(), and guild_member().

◆ user_id

snowflake dpp::guild_member::user_id

The documentation for this class was generated from the following files: