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

A definition of a discord thread. A thread is a superset of a channel. Not to be confused with std::thread! More...

#include <channel.h>

+ Inheritance diagram for dpp::thread:
+ Collaboration diagram for dpp::thread:

Public Member Functions

 thread ()
 Construct a new thread object. More...
 
bool is_news_thread () const
 Returns true if the thread is within an announcement channel. More...
 
bool is_public_thread () const
 Returns true if the channel is a public thread. More...
 
bool is_private_thread () const
 Returns true if the channel is a private thread. More...
 
threadfill_from_json (nlohmann::json *j)
 
virtual ~thread ()
 Destroy the thread object. More...
 
std::string build_json (bool with_id=false) const
 Build json for this thread object. More...
 
channelset_name (const std::string &name)
 Set name of this channel object. More...
 
channelset_topic (const std::string &topic)
 Set topic of this channel object. More...
 
channelset_type (const channel_type &type)
 Set type of this channel object. More...
 
channelset_flags (const uint8_t flags)
 Set flags for this channel object. More...
 
channeladd_flag (const channel_flags flag)
 Add (bitwise OR) a flag to this channel object. More...
 
channelremove_flag (const channel_flags flag)
 Remove (bitwise NOT AND) a flag from this channel object. More...
 
channelset_position (const uint16_t position)
 Set position of this channel object. More...
 
channelset_guild_id (const snowflake guild_id)
 Set guild_id of this channel object. More...
 
channelset_parent_id (const snowflake parent_id)
 Set parent_id of this channel object. More...
 
channelset_user_limit (const uint8_t user_limit)
 Set user_limit of this channel object. More...
 
channelset_bitrate (const uint16_t bitrate)
 Set bitrate of this channel object. More...
 
channelset_nsfw (const bool is_nsfw)
 Set nsfw property of this channel object. More...
 
channelset_lock_permissions (const bool is_lock_permissions)
 Set lock permissions property of this channel object Used only with the reorder channels method. More...
 
channelset_rate_limit_per_user (const uint16_t rate_limit_per_user)
 Set rate_limit_per_user of this channel object. More...
 
channeladd_permission_overwrite (const snowflake id, const overwrite_type type, const uint64_t allowed_permissions, const uint64_t denied_permissions)
 Add a permission_overwrite to this channel object. More...
 
std::string get_mention () const
 Get the mention ping for the channel. More...
 
permission get_user_permissions (const class user *user) const
 Get the overall permissions for a member in this channel, including channel overwrites, role permissions and admin privileges. More...
 
permission get_user_permissions (const class guild_member &member) const
 Get the overall permissions for a member in this channel, including channel overwrites, role permissions and admin privileges. More...
 
std::map< snowflake, class guild_member * > get_members ()
 Return a map of members on the channel, built from the guild's member list based on which members have the VIEW_CHANNEL permission. Does not return reliable information for voice channels, use dpp::channel::get_voice_members() instead for this. More...
 
std::map< snowflake, voicestateget_voice_members ()
 Get a map of members in this channel, if it is a voice channel. The map is keyed by snowflake id of the user. More...
 
std::string get_icon_url (uint16_t size=0) const
 Get the channel's icon url (if its a group DM), otherwise returns an empty string. More...
 
bool is_nsfw () const
 Returns true if the channel is NSFW gated. More...
 
bool is_locked_permissions () const
 Returns true if the permissions are to be synced with the category it is in. Used only and set manually when using the reorder channels method. More...
 
bool is_text_channel () const
 Returns true if the channel is a text channel. More...
 
bool is_dm () const
 Returns true if the channel is a DM. More...
 
bool is_voice_channel () const
 Returns true if the channel is a voice channel. More...
 
bool is_group_dm () const
 Returns true if the channel is a group DM channel. More...
 
bool is_category () const
 Returns true if the channel is a category. More...
 
bool is_forum () const
 Returns true if the channel is a forum. More...
 
bool is_news_channel () const
 Returns true if the channel is an announcement channel. More...
 
bool is_store_channel () const
 Returns true if the channel is a store channel. More...
 
bool is_stage_channel () const
 Returns true if the channel is a stage channel. More...
 
bool is_video_auto () const
 Returns true if video quality is auto. More...
 
bool is_video_720p () const
 Returns true if video quality is 720p. More...
 
bool is_pinned_thread () const
 Returns true if channel is a pinned thread in forum. More...
 
double get_creation_time () const
 Get the creation time of this object according to Discord. More...
 
bool operator== (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 
bool operator!= (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 

Public Attributes

thread_member member
 Thread member of current user if joined to the thread. Note this is only set by certain api calls otherwise contains default data. More...
 
thread_metadata metadata
 
message msg
 
std::vector< snowflakeapplied_tags
 
uint32_t total_messages_sent
 Number of messages ever sent in the thread. It's similar to thread::message_count on message creation, but will not decrement the number when a message is deleted. More...
 
uint8_t message_count
 Number of messages (not including the initial message or deleted messages) of the thread. For threads created before July 1, 2022, the message count is inaccurate when it's greater than 50. More...
 
uint8_t member_count
 
std::string name
 
std::string topic
 
std::string rtc_region
 Voice region if set for voice channel, otherwise empty string. More...
 
std::vector< snowflakerecipients
 
std::vector< permission_overwritepermission_overwrites
 
std::vector< forum_tagavailable_tags
 
std::variant< std::monostate, snowflake, std::string > default_reaction
 The emoji to show as the default reaction button on a forum post. Contains either nothing, the id of a guild's custom emoji or the unicode character of the emoji. More...
 
utility::iconhash icon
 Channel icon (for group DMs) More...
 
snowflake owner_id
 
snowflake parent_id
 
snowflake guild_id
 
snowflake last_message_id
 
time_t last_pin_timestamp
 
permission permissions
 This is only filled when the channel is part of the resolved set sent within an interaction. Any other time it contains zero. When filled, it contains the calculated permission bitmask of the user issuing the command within this channel. More...
 
uint16_t position
 
uint16_t bitrate
 
uint16_t rate_limit_per_user
 
uint16_t default_thread_rate_limit_per_user
 
auto_archive_duration_t default_auto_archive_duration
 Default duration, copied onto newly created threads. Used by the clients, not the API. Threads will stop showing in the channel list after the specified period of inactivity. Defaults to dpp::arc_1_day. More...
 
default_forum_sort_order_t default_sort_order
 
uint8_t flags
 
uint8_t user_limit
 
snowflake id
 Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata. More...
 

Detailed Description

A definition of a discord thread. A thread is a superset of a channel. Not to be confused with std::thread!

Constructor & Destructor Documentation

◆ thread()

dpp::thread::thread ( )

Construct a new thread object.

◆ ~thread()

virtual dpp::thread::~thread ( )
virtual

Destroy the thread object.

Member Function Documentation

◆ add_flag()

channel & dpp::channel::add_flag ( const channel_flags  flag)
inherited

Add (bitwise OR) a flag to this channel object.

Parameters
flagFlag bit to add from dpp::channel_flags
Returns
Reference to self, so these method calls may be chained

◆ add_permission_overwrite()

channel & dpp::channel::add_permission_overwrite ( const snowflake  id,
const overwrite_type  type,
const uint64_t  allowed_permissions,
const uint64_t  denied_permissions 
)
inherited

Add a permission_overwrite to this channel object.

Parameters
idID of the role or the member you want to add overwrite for
typetype of overwrite
allowed_permissionsbitmask of allowed permissions (refer to enum dpp::permissions) for this user/role in this channel
denied_permissionsbitmask of denied permissions (refer to enum dpp::permissions) for this user/role in this channel
Returns
Reference to self, so these method calls may be chained

◆ build_json()

std::string dpp::thread::build_json ( bool  with_id = false) const
virtual

Build json for this thread object.

Parameters
with_idinclude the ID in the json
Returns
std::string JSON string

Reimplemented from dpp::channel.

◆ fill_from_json()

thread & dpp::thread::fill_from_json ( nlohmann::json *  j)

Read class values from json object

Parameters
jA json object to read from
Returns
A reference to self

◆ get_creation_time()

double dpp::managed::get_creation_time ( ) const
inherited

Get the creation time of this object according to Discord.

Returns
double creation time inferred from the snowflake ID. The minimum possible value is the first second of 2015.

◆ get_icon_url()

std::string dpp::channel::get_icon_url ( uint16_t  size = 0) const
inherited

Get the channel's icon url (if its a group DM), otherwise returns an empty string.

Parameters
sizeThe size of the icon in pixels. It can be any power of two between 16 and 4096. if not specified, the default sized icon is returned.
Returns
std::string icon url or empty string

◆ get_members()

std::map< snowflake, class guild_member * > dpp::channel::get_members ( )
inherited

Return a map of members on the channel, built from the guild's member list based on which members have the VIEW_CHANNEL permission. Does not return reliable information for voice channels, use dpp::channel::get_voice_members() instead for this.

Returns
A map of guild members keyed by user id.
Note
If the guild this channel belongs to is not in the cache, the function will always return 0.

◆ get_mention()

std::string dpp::channel::get_mention ( ) const
inherited

Get the mention ping for the channel.

Returns
std::string mention

◆ get_user_permissions() [1/2]

permission dpp::channel::get_user_permissions ( const class guild_member member) const
inherited

Get the overall permissions for a member in this channel, including channel overwrites, role permissions and admin privileges.

Parameters
memberThe member to resolve the permissions for
Returns
permission Permission overwrites for the member. Made of bits in dpp::permissions.
Note
Requires role cache to be enabled (it's enabled by default).
This is an alias for guild::permission_overwrites and searches for the guild in the cache, so consider using guild::permission_overwrites if you already have the guild object.

◆ get_user_permissions() [2/2]

permission dpp::channel::get_user_permissions ( const class user user) const
inherited

Get the overall permissions for a member in this channel, including channel overwrites, role permissions and admin privileges.

Parameters
userThe user to resolve the permissions for
Returns
permission Permission overwrites for the member. Made of bits in dpp::permissions.
Note
Requires role cache to be enabled (it's enabled by default).
This is an alias for guild::permission_overwrites and searches for the guild in the cache, so consider using guild::permission_overwrites if you already have the guild object.
Warning
The method will search for the guild member in the cache by the users id. If the guild member is not in cache, the method will always return 0.

◆ get_voice_members()

std::map< snowflake, voicestate > dpp::channel::get_voice_members ( )
inherited

Get a map of members in this channel, if it is a voice channel. The map is keyed by snowflake id of the user.

Returns
std::map<snowflake, voicestate> The voice members of the channel

◆ is_category()

bool dpp::channel::is_category ( ) const
inherited

Returns true if the channel is a category.

Returns
true if a category

◆ is_dm()

bool dpp::channel::is_dm ( ) const
inherited

Returns true if the channel is a DM.

Returns
true if is a DM

◆ is_forum()

bool dpp::channel::is_forum ( ) const
inherited

Returns true if the channel is a forum.

Returns
true if a forum

◆ is_group_dm()

bool dpp::channel::is_group_dm ( ) const
inherited

Returns true if the channel is a group DM channel.

Returns
true if group DM

◆ is_locked_permissions()

bool dpp::channel::is_locked_permissions ( ) const
inherited

Returns true if the permissions are to be synced with the category it is in. Used only and set manually when using the reorder channels method.

Returns
true if keeping permissions

◆ is_news_channel()

bool dpp::channel::is_news_channel ( ) const
inherited

Returns true if the channel is an announcement channel.

Returns
true if announcement channel

◆ is_news_thread()

bool dpp::thread::is_news_thread ( ) const

Returns true if the thread is within an announcement channel.

Returns
true if announcement thread

◆ is_nsfw()

bool dpp::channel::is_nsfw ( ) const
inherited

Returns true if the channel is NSFW gated.

Returns
true if NSFW

◆ is_pinned_thread()

bool dpp::channel::is_pinned_thread ( ) const
inherited

Returns true if channel is a pinned thread in forum.

Returns
true, if channel is a pinned thread in forum

◆ is_private_thread()

bool dpp::thread::is_private_thread ( ) const

Returns true if the channel is a private thread.

Returns
true if private thread

◆ is_public_thread()

bool dpp::thread::is_public_thread ( ) const

Returns true if the channel is a public thread.

Returns
true if public thread

◆ is_stage_channel()

bool dpp::channel::is_stage_channel ( ) const
inherited

Returns true if the channel is a stage channel.

Returns
true if stage channel

◆ is_store_channel()

bool dpp::channel::is_store_channel ( ) const
inherited

Returns true if the channel is a store channel.

Deprecated:
store channels are deprecated by Discord
Returns
true if store channel

◆ is_text_channel()

bool dpp::channel::is_text_channel ( ) const
inherited

Returns true if the channel is a text channel.

Returns
true if text channel

◆ is_video_720p()

bool dpp::channel::is_video_720p ( ) const
inherited

Returns true if video quality is 720p.

Returns
true if video quality is 720p

◆ is_video_auto()

bool dpp::channel::is_video_auto ( ) const
inherited

Returns true if video quality is auto.

Returns
true if video quality is auto

◆ is_voice_channel()

bool dpp::channel::is_voice_channel ( ) const
inherited

Returns true if the channel is a voice channel.

Returns
true if voice channel

◆ operator!=()

bool dpp::managed::operator!= ( const managed other) const
noexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are not the same id
false objects are the same id

◆ operator==()

bool dpp::managed::operator== ( const managed other) const
noexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are the same id
false objects are not the same id

◆ remove_flag()

channel & dpp::channel::remove_flag ( const channel_flags  flag)
inherited

Remove (bitwise NOT AND) a flag from this channel object.

Parameters
flagFlag bit to remove from dpp::channel_flags
Returns
Reference to self, so these method calls may be chained

◆ set_bitrate()

channel & dpp::channel::set_bitrate ( const uint16_t  bitrate)
inherited

Set bitrate of this channel object.

Parameters
bitrateBitrate to set
Returns
Reference to self, so these method calls may be chained

◆ set_flags()

channel & dpp::channel::set_flags ( const uint8_t  flags)
inherited

Set flags for this channel object.

Parameters
flagsFlag bitmask to set from dpp::channel_flags
Returns
Reference to self, so these method calls may be chained

◆ set_guild_id()

channel & dpp::channel::set_guild_id ( const snowflake  guild_id)
inherited

Set guild_id of this channel object.

Parameters
guild_idGuild ID to set
Returns
Reference to self, so these method calls may be chained

◆ set_lock_permissions()

channel & dpp::channel::set_lock_permissions ( const bool  is_lock_permissions)
inherited

Set lock permissions property of this channel object Used only with the reorder channels method.

Parameters
is_lock_permissionstrue, if we are to inherit permissions from the category
Returns
Reference to self, so these method calls may be chained

◆ set_name()

channel & dpp::channel::set_name ( const std::string &  name)
inherited

Set name of this channel object.

Parameters
nameName to set
Returns
Reference to self, so these method calls may be chained
Note
name will be truncated to 100 chars, if longer
Exceptions
dpp::length_exceptionif length < 1

◆ set_nsfw()

channel & dpp::channel::set_nsfw ( const bool  is_nsfw)
inherited

Set nsfw property of this channel object.

Parameters
is_nsfwtrue, if channel is nsfw
Returns
Reference to self, so these method calls may be chained

◆ set_parent_id()

channel & dpp::channel::set_parent_id ( const snowflake  parent_id)
inherited

Set parent_id of this channel object.

Parameters
parent_idParent ID to set
Returns
Reference to self, so these method calls may be chained

◆ set_position()

channel & dpp::channel::set_position ( const uint16_t  position)
inherited

Set position of this channel object.

Parameters
positionPosition to set
Returns
Reference to self, so these method calls may be chained

◆ set_rate_limit_per_user()

channel & dpp::channel::set_rate_limit_per_user ( const uint16_t  rate_limit_per_user)
inherited

Set rate_limit_per_user of this channel object.

Parameters
rate_limit_per_userrate_limit_per_user (slowmode in sec) to set
Returns
Reference to self, so these method calls may be chained

◆ set_topic()

channel & dpp::channel::set_topic ( const std::string &  topic)
inherited

Set topic of this channel object.

Parameters
topicTopic to set
Returns
Reference to self, so these method calls may be chained
Note
topic will be truncated to 1024 chars, if longer

◆ set_type()

channel & dpp::channel::set_type ( const channel_type type)
inherited

Set type of this channel object.

Parameters
typeChannel type to set
Returns
Reference to self, so these method calls may be chained

◆ set_user_limit()

channel & dpp::channel::set_user_limit ( const uint8_t  user_limit)
inherited

Set user_limit of this channel object.

Parameters
user_limitLimit to set
Returns
Reference to self, so these method calls may be chained

Member Data Documentation

◆ applied_tags

std::vector<snowflake> dpp::thread::applied_tags

A list of dpp::forum_tag IDs that have been applied to a thread in a forum channel

◆ available_tags

std::vector<forum_tag> dpp::channel::available_tags
inherited

A set of tags that can be used in a forum channel

◆ bitrate

uint16_t dpp::channel::bitrate
inherited

the bitrate (in bits) of the voice channel

◆ default_auto_archive_duration

auto_archive_duration_t dpp::channel::default_auto_archive_duration
inherited

Default duration, copied onto newly created threads. Used by the clients, not the API. Threads will stop showing in the channel list after the specified period of inactivity. Defaults to dpp::arc_1_day.

◆ default_reaction

std::variant<std::monostate, snowflake, std::string> dpp::channel::default_reaction
inherited

The emoji to show as the default reaction button on a forum post. Contains either nothing, the id of a guild's custom emoji or the unicode character of the emoji.

◆ default_sort_order

default_forum_sort_order_t dpp::channel::default_sort_order
inherited

the default sort order type used to order posts in forum channels

◆ default_thread_rate_limit_per_user

uint16_t dpp::channel::default_thread_rate_limit_per_user
inherited

The initial rate_limit_per_user to set on newly created threads in a channel. This field is copied to the thread at creation time and does not live update

◆ flags

uint8_t dpp::channel::flags
inherited

Flags bitmap

◆ guild_id

snowflake dpp::channel::guild_id
inherited

Guild id of the guild that owns the channel

◆ icon

utility::iconhash dpp::channel::icon
inherited

Channel icon (for group DMs)

◆ id

snowflake dpp::managed::id
inherited

Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.

◆ last_message_id

snowflake dpp::channel::last_message_id
inherited

ID of last message to be sent to the channel (may not point to an existing or valid message or thread)

◆ last_pin_timestamp

time_t dpp::channel::last_pin_timestamp
inherited

Timestamp of last pinned message

◆ member

thread_member dpp::thread::member

Thread member of current user if joined to the thread. Note this is only set by certain api calls otherwise contains default data.

◆ member_count

uint8_t dpp::thread::member_count

Approximate count of members in a thread (threads)

◆ message_count

uint8_t dpp::thread::message_count

Number of messages (not including the initial message or deleted messages) of the thread. For threads created before July 1, 2022, the message count is inaccurate when it's greater than 50.

◆ metadata

thread_metadata dpp::thread::metadata

Thread metadata (threads)

◆ msg

message dpp::thread::msg

Created message. Only filled within the cluster::thread_create_in_forum() method

◆ name

std::string dpp::channel::name
inherited

Channel name (1-100 characters)

◆ owner_id

snowflake dpp::channel::owner_id
inherited

User ID of the creator for group DMs or threads

◆ parent_id

snowflake dpp::channel::parent_id
inherited

Parent ID (for guild channels: id of the parent category, for threads: id of the text channel this thread was created)

◆ permission_overwrites

std::vector<permission_overwrite> dpp::channel::permission_overwrites
inherited

Permission overwrites to apply to base permissions

◆ permissions

permission dpp::channel::permissions
inherited

This is only filled when the channel is part of the resolved set sent within an interaction. Any other time it contains zero. When filled, it contains the calculated permission bitmask of the user issuing the command within this channel.

◆ position

uint16_t dpp::channel::position
inherited

Sorting position, lower number means higher up the list

◆ rate_limit_per_user

uint16_t dpp::channel::rate_limit_per_user
inherited

amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected

◆ recipients

std::vector<snowflake> dpp::channel::recipients
inherited

DM recipients

◆ rtc_region

std::string dpp::channel::rtc_region
inherited

Voice region if set for voice channel, otherwise empty string.

◆ topic

std::string dpp::channel::topic
inherited

Channel topic (0-4096 characters for forum channels, 0-1024 characters for all others)

◆ total_messages_sent

uint32_t dpp::thread::total_messages_sent

Number of messages ever sent in the thread. It's similar to thread::message_count on message creation, but will not decrement the number when a message is deleted.

◆ user_limit

uint8_t dpp::channel::user_limit
inherited

Maximum user limit for voice channels (0-99)

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ 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