D++ (DPP)
C++ Discord API Bot Library
|
A definition of a discord channel. There are one of these for every channel type except threads. Threads are special snowflakes. Get it? A Discord pun. Hahaha. .... I'll get my coat. More...
#include <channel.h>
Public Member Functions | |
channel () | |
virtual | ~channel () |
channel & | fill_from_json (nlohmann::json *j) |
virtual std::string | build_json (bool with_id=false) const |
Build json for this channel object. More... | |
channel & | set_name (const std::string &name) |
Set name of this channel object. More... | |
channel & | set_topic (const std::string &topic) |
Set topic of this channel object. More... | |
channel & | set_type (channel_type type) |
Set type of this channel object. More... | |
channel & | set_default_forum_layout (forum_layout_type layout_type) |
Set the default forum layout type for the forum channel. More... | |
channel & | set_default_sort_order (default_forum_sort_order_t sort_order) |
Set the default forum sort order for the forum channel. More... | |
channel & | set_flags (const uint16_t flags) |
Set flags for this channel object. More... | |
channel & | add_flag (const channel_flags flag) |
Add (bitwise OR) a flag to this channel object. More... | |
channel & | remove_flag (const channel_flags flag) |
Remove (bitwise NOT AND) a flag from this channel object. More... | |
channel & | set_position (const uint16_t position) |
Set position of this channel object. More... | |
channel & | set_guild_id (const snowflake guild_id) |
Set guild_id of this channel object. More... | |
channel & | set_parent_id (const snowflake parent_id) |
Set parent_id of this channel object. More... | |
channel & | set_user_limit (const uint8_t user_limit) |
Set user_limit of this channel object. More... | |
channel & | set_bitrate (const uint16_t bitrate) |
Set bitrate of this channel object. More... | |
channel & | set_nsfw (const bool is_nsfw) |
Set nsfw property of this channel object. More... | |
channel & | set_lock_permissions (const bool is_lock_permissions) |
Set lock permissions property of this channel object Used only with the reorder channels method. More... | |
channel & | set_rate_limit_per_user (const uint16_t rate_limit_per_user) |
Set rate_limit_per_user of this channel object. More... | |
channel & | add_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... | |
channel_type | get_type () const |
Get the channel type. More... | |
forum_layout_type | get_default_forum_layout () const |
Get the default forum layout type used to display posts in forum channels. 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, voicestate > | get_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 image_type format=i_png) 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... | |
bool | is_tag_required () const |
Returns true if a tag is required to be specified when creating a thread in a forum channel. 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... | |
Static Public Member Functions | |
static std::string | get_mention (const snowflake &id) |
Create a mentionable channel. More... | |
Public Attributes | |
std::string | name |
std::string | topic |
std::string | rtc_region |
Voice region if set for voice channel, otherwise empty string. More... | |
std::vector< snowflake > | recipients |
std::vector< permission_overwrite > | permission_overwrites |
std::vector< forum_tag > | available_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 |
uint16_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... | |
A definition of a discord channel. There are one of these for every channel type except threads. Threads are special snowflakes. Get it? A Discord pun. Hahaha. .... I'll get my coat.
dpp::channel::channel | ( | ) |
Constructor
|
virtual |
Destructor
channel & dpp::channel::add_flag | ( | const channel_flags | flag | ) |
Add (bitwise OR) a flag to this channel object.
flag | Flag bit to add from dpp::channel_flags |
channel & dpp::channel::add_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.
id | ID of the role or the member you want to add overwrite for |
type | type of overwrite |
allowed_permissions | bitmask of allowed permissions (refer to enum dpp::permissions) for this user/role in this channel |
denied_permissions | bitmask of denied permissions (refer to enum dpp::permissions) for this user/role in this channel |
|
virtual |
Build json for this channel object.
with_id | include the ID in the json |
Reimplemented from dpp::json_interface< channel >.
Reimplemented in dpp::thread.
channel & dpp::channel::fill_from_json | ( | nlohmann::json * | j | ) |
Read class values from json object
j | A json object to read from |
|
inherited |
Get the creation time of this object according to Discord.
forum_layout_type dpp::channel::get_default_forum_layout | ( | ) | const |
Get the default forum layout type used to display posts in forum channels.
std::string dpp::channel::get_icon_url | ( | uint16_t | size = 0 , |
const image_type | format = i_png |
||
) | const |
Get the channel's icon url (if its a group DM), otherwise returns an empty string.
size | The size of the icon in pixels. It can be any power of two between 16 and 4096, otherwise the default sized icon is returned. |
format | The format to use for the avatar. It can be one of i_webp , i_jpg or i_png . |
std::map< snowflake, class guild_member * > dpp::channel::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.
std::string dpp::channel::get_mention | ( | ) | const |
Get the mention ping for the channel.
|
static |
Create a mentionable channel.
id | The ID of the channel. |
channel_type dpp::channel::get_type | ( | ) | const |
Get the channel type.
permission dpp::channel::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.
member | The member to resolve the permissions for |
permission dpp::channel::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.
user | The user to resolve the permissions for |
std::map< snowflake, voicestate > dpp::channel::get_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.
bool dpp::channel::is_category | ( | ) | const |
Returns true if the channel is a category.
bool dpp::channel::is_dm | ( | ) | const |
Returns true if the channel is a DM.
bool dpp::channel::is_forum | ( | ) | const |
Returns true if the channel is a forum.
bool dpp::channel::is_group_dm | ( | ) | const |
Returns true if the channel is a group DM channel.
bool dpp::channel::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.
bool dpp::channel::is_news_channel | ( | ) | const |
Returns true if the channel is an announcement channel.
bool dpp::channel::is_nsfw | ( | ) | const |
Returns true if the channel is NSFW gated.
bool dpp::channel::is_pinned_thread | ( | ) | const |
Returns true if channel is a pinned thread in forum.
bool dpp::channel::is_stage_channel | ( | ) | const |
Returns true if the channel is a stage channel.
bool dpp::channel::is_store_channel | ( | ) | const |
Returns true if the channel is a store channel.
bool dpp::channel::is_tag_required | ( | ) | const |
Returns true if a tag is required to be specified when creating a thread in a forum channel.
bool dpp::channel::is_text_channel | ( | ) | const |
Returns true if the channel is a text channel.
bool dpp::channel::is_video_720p | ( | ) | const |
Returns true if video quality is 720p.
bool dpp::channel::is_video_auto | ( | ) | const |
Returns true if video quality is auto.
bool dpp::channel::is_voice_channel | ( | ) | const |
Returns true if the channel is a voice channel.
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
channel & dpp::channel::remove_flag | ( | const channel_flags | flag | ) |
Remove (bitwise NOT AND) a flag from this channel object.
flag | Flag bit to remove from dpp::channel_flags |
channel & dpp::channel::set_bitrate | ( | const uint16_t | bitrate | ) |
Set bitrate of this channel object.
bitrate | Bitrate to set (in kilobits) |
channel & dpp::channel::set_default_forum_layout | ( | forum_layout_type | layout_type | ) |
Set the default forum layout type for the forum channel.
layout_type | The layout type |
channel & dpp::channel::set_default_sort_order | ( | default_forum_sort_order_t | sort_order | ) |
Set the default forum sort order for the forum channel.
sort_order | The sort order |
channel & dpp::channel::set_flags | ( | const uint16_t | flags | ) |
Set flags for this channel object.
flags | Flag bitmask to set from dpp::channel_flags |
Set guild_id of this channel object.
guild_id | Guild ID to set |
channel & dpp::channel::set_lock_permissions | ( | const bool | is_lock_permissions | ) |
Set lock permissions property of this channel object Used only with the reorder channels method.
is_lock_permissions | true, if we are to inherit permissions from the category |
channel & dpp::channel::set_name | ( | const std::string & | name | ) |
Set name of this channel object.
name | Name to set |
dpp::length_exception | if length < 1 |
channel & dpp::channel::set_nsfw | ( | const bool | is_nsfw | ) |
Set nsfw property of this channel object.
is_nsfw | true, if channel is nsfw |
Set parent_id of this channel object.
parent_id | Parent ID to set |
channel & dpp::channel::set_position | ( | const uint16_t | position | ) |
Set position of this channel object.
position | Position to set |
channel & dpp::channel::set_rate_limit_per_user | ( | const uint16_t | rate_limit_per_user | ) |
Set rate_limit_per_user of this channel object.
rate_limit_per_user | rate_limit_per_user (slowmode in sec) to set |
channel & dpp::channel::set_topic | ( | const std::string & | topic | ) |
Set topic of this channel object.
topic | Topic to set |
channel & dpp::channel::set_type | ( | channel_type | type | ) |
Set type of this channel object.
type | Channel type to set |
channel & dpp::channel::set_user_limit | ( | const uint8_t | user_limit | ) |
Set user_limit of this channel object.
user_limit | Limit to set |
std::vector<forum_tag> dpp::channel::available_tags |
A set of tags that can be used in a forum channel
uint16_t dpp::channel::bitrate |
the bitrate (in kilobits) of the voice channel
auto_archive_duration_t dpp::channel::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.
std::variant<std::monostate, snowflake, std::string> dpp::channel::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.
default_forum_sort_order_t dpp::channel::default_sort_order |
the default sort order type used to order posts in forum channels
uint16_t dpp::channel::default_thread_rate_limit_per_user |
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
uint16_t dpp::channel::flags |
Flags bitmap (dpp::channel_flags)
snowflake dpp::channel::guild_id |
Guild id of the guild that owns the channel
utility::iconhash dpp::channel::icon |
Channel icon (for group DMs)
|
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.
snowflake dpp::channel::last_message_id |
ID of last message to be sent to the channel (may not point to an existing or valid message or thread)
time_t dpp::channel::last_pin_timestamp |
Timestamp of last pinned message
std::string dpp::channel::name |
Channel name (1-100 characters)
snowflake dpp::channel::owner_id |
User ID of the creator for group DMs or threads
snowflake dpp::channel::parent_id |
Parent ID (for guild channels: id of the parent category, for threads: id of the text channel this thread was created)
std::vector<permission_overwrite> dpp::channel::permission_overwrites |
Permission overwrites to apply to base permissions
permission dpp::channel::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.
uint16_t dpp::channel::position |
Sorting position, lower number means higher up the list
uint16_t dpp::channel::rate_limit_per_user |
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
std::vector<snowflake> dpp::channel::recipients |
DM recipients
std::string dpp::channel::rtc_region |
Voice region if set for voice channel, otherwise empty string.
std::string dpp::channel::topic |
Channel topic (0-4096 characters for forum channels, 0-1024 characters for all others)
uint8_t dpp::channel::user_limit |
Maximum user limit for voice channels (0-99)