D++ (DPP)
C++ Discord API Bot Library
|
Represents messages sent and received on Discord. More...
#include <message.h>
Classes | |
struct | allowed_ref |
Allowed mentions details. More... | |
struct | message_interaction_struct |
Reference to an interaction. More... | |
struct | message_ref |
Reference to another message, e.g. a reply. More... | |
Public Member Functions | |
message () | |
Construct a new message object. More... | |
message (class cluster *o) | |
Construct a new message object. More... | |
virtual | ~message () |
Destroy the message object. More... | |
message (snowflake channel_id, const std::string &content, message_type type=mt_default) | |
Construct a new message object with a channel and content. More... | |
message (snowflake channel_id, const embed &_embed) | |
Construct a new message object with a channel and content. More... | |
message (const std::string &content, message_type type=mt_default) | |
Construct a new message object with content. More... | |
message & | set_reference (snowflake _message_id, snowflake _guild_id=0, snowflake _channel_id=0, bool fail_if_not_exists=false) |
Set the original message reference for replies/crossposts. More... | |
message & | set_allowed_mentions (bool _parse_users, bool _parse_roles, bool _parse_everyone, bool _replied_user, const std::vector< snowflake > &users, const std::vector< snowflake > &roles) |
Set the allowed mentions object for pings on the message. More... | |
message & | fill_from_json (nlohmann::json *j, cache_policy_t cp={cp_aggressive, cp_aggressive, cp_aggressive}) |
virtual std::string | build_json (bool with_id=false, bool is_interaction_response=false) const |
bool | is_crossposted () const |
Returns true if the message was crossposted to other servers. More... | |
bool | is_crosspost () const |
Returns true if posted from other servers announcement channel via webhook. More... | |
bool | suppress_embeds () const |
True if embeds have been removed. More... | |
bool | is_source_message_deleted () const |
True if source message was deleted. More... | |
bool | is_urgent () const |
True if urgent. More... | |
bool | has_thread () const |
True if has thread attached. More... | |
bool | is_ephemeral () const |
True if ephemeral (visible only to issuer of a slash command) More... | |
bool | is_loading () const |
True if loading. More... | |
bool | is_thread_mention_failed () const |
Returns true if this message failed to mention some roles and add their members to the thread. More... | |
bool | suppress_notifications () const |
True if the message will not trigger push and desktop notifications. More... | |
message & | add_component (const component &c) |
Add a component (button) to message. More... | |
message & | add_embed (const embed &e) |
Add an embed to message. More... | |
message & | set_flags (uint16_t f) |
Set the flags. More... | |
message & | set_type (message_type t) |
Set the message type. More... | |
message & | set_filename (const std::string &fn) |
Set the filename of the last file in list. More... | |
message & | set_file_content (const std::string &fc) |
Set the file content of the last file in list. More... | |
message & | add_file (const std::string &filename, const std::string &filecontent) |
Add a file to the message. More... | |
message & | set_content (const std::string &c) |
Set the message content. More... | |
message & | set_channel_id (snowflake _channel_id) |
Set the channel id. More... | |
message & | set_guild_id (snowflake _guild_id) |
Set the channel id. More... | |
bool | is_dm () const |
Returns true if the message is from a DM. 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 | |
snowflake | channel_id |
snowflake | guild_id |
user | author |
guild_member | member |
std::string | content |
std::vector< dpp::component > | components |
time_t | sent |
time_t | edited |
std::vector< std::pair< user, guild_member > > | mentions |
std::vector< snowflake > | mention_roles |
std::vector< channel > | mention_channels |
std::vector< attachment > | attachments |
std::vector< embed > | embeds |
std::vector< reaction > | reactions |
std::string | nonce |
snowflake | webhook_id |
std::vector< sticker > | stickers |
std::vector< std::string > | filename |
std::vector< std::string > | filecontent |
struct dpp::message::message_ref | message_reference |
struct dpp::message::message_interaction_struct | interaction |
struct dpp::message::allowed_ref | allowed_mentions |
class cluster * | owner |
The cluster which created this message object. More... | |
message_type | type |
uint16_t | flags |
bool | pinned |
bool | tts |
bool | mention_everyone |
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... | |
Represents messages sent and received on Discord.
dpp::message::message | ( | ) |
Construct a new message object.
dpp::message::message | ( | class cluster * | o | ) |
Construct a new message object.
o | Owning cluster, passed down to various things such as dpp::attachment. Owning cluster is optional (can be nullptr) and if nulled, will prevent some functions such as attachment::download from functioning (they will throw, if used) |
|
virtual |
Destroy the message object.
dpp::message::message | ( | snowflake | channel_id, |
const std::string & | content, | ||
message_type | type = mt_default |
||
) |
Construct a new message object with a channel and content.
channel_id | The channel to send the message to |
content | The content of the message. It will be truncated to the maximum length of 4000 UTF-8 characters. |
type | The message type to create |
Construct a new message object with a channel and content.
channel_id | The channel to send the message to |
_embed | An embed to send |
dpp::message::message | ( | const std::string & | content, |
message_type | type = mt_default |
||
) |
Construct a new message object with content.
content | The content of the message. It will be truncated to the maximum length of 4000 UTF-8 characters. |
type | The message type to create |
Add a component (button) to message.
c | component to add |
Add an embed to message.
e | embed to add |
message & dpp::message::add_file | ( | const std::string & | filename, |
const std::string & | filecontent | ||
) |
Add a file to the message.
filename | filename |
filecontent | raw file content contained in std::string |
|
virtual |
Build JSON from this object.
with_id | True if the ID is to be included in the built JSON |
is_interaction_response | Set to true if this message is intended to be included in an interaction response. This will exclude some fields that are not valid in interactions at this time. |
message & dpp::message::fill_from_json | ( | nlohmann::json * | j, |
cache_policy_t | cp = {cp_aggressive, cp_aggressive, cp_aggressive} |
||
) |
Fill this object from json.
j | JSON object to fill from |
cp | Cache policy for user records, whether or not we cache users when a message is received |
|
inherited |
Get the creation time of this object according to Discord.
bool dpp::message::has_thread | ( | ) | const |
True if has thread attached.
bool dpp::message::is_crosspost | ( | ) | const |
Returns true if posted from other servers announcement channel via webhook.
bool dpp::message::is_crossposted | ( | ) | const |
Returns true if the message was crossposted to other servers.
bool dpp::message::is_dm | ( | ) | const |
Returns true if the message is from a DM.
bool dpp::message::is_ephemeral | ( | ) | const |
True if ephemeral (visible only to issuer of a slash command)
bool dpp::message::is_loading | ( | ) | const |
True if loading.
bool dpp::message::is_source_message_deleted | ( | ) | const |
True if source message was deleted.
bool dpp::message::is_thread_mention_failed | ( | ) | const |
Returns true if this message failed to mention some roles and add their members to the thread.
bool dpp::message::is_urgent | ( | ) | const |
True if urgent.
|
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 |
message & dpp::message::set_allowed_mentions | ( | bool | _parse_users, |
bool | _parse_roles, | ||
bool | _parse_everyone, | ||
bool | _replied_user, | ||
const std::vector< snowflake > & | users, | ||
const std::vector< snowflake > & | roles | ||
) |
Set the allowed mentions object for pings on the message.
_parse_users | whether or not to parse users in the message content or embeds |
_parse_roles | whether or not to parse roles in the message content or embeds |
_parse_everyone | whether or not to parse everyone/here in the message content or embeds |
_replied_user | if set to true and this is a reply, then ping the user we reply to |
users | list of user ids to allow pings for |
roles | list of role ids to allow pings for |
Set the channel id.
_channel_id | channel id |
message & dpp::message::set_content | ( | const std::string & | c | ) |
Set the message content.
c | message content. It will be truncated to the maximum length of 4000 UTF-8 characters. |
message & dpp::message::set_file_content | ( | const std::string & | fc | ) |
Set the file content of the last file in list.
fc | raw file content contained in std::string |
message & dpp::message::set_filename | ( | const std::string & | fn | ) |
Set the filename of the last file in list.
fn | filename |
message & dpp::message::set_flags | ( | uint16_t | f | ) |
Set the channel id.
_guild_id | channel id |
message & dpp::message::set_reference | ( | snowflake | _message_id, |
snowflake | _guild_id = 0 , |
||
snowflake | _channel_id = 0 , |
||
bool | fail_if_not_exists = false |
||
) |
Set the original message reference for replies/crossposts.
_message_id | message id to reply to |
_guild_id | guild id to reply to (optional) |
_channel_id | channel id to reply to (optional) |
fail_if_not_exists | true if the message send should fail if these values are invalid (optional) |
message & dpp::message::set_type | ( | message_type | t | ) |
Set the message type.
t | type to set |
bool dpp::message::suppress_embeds | ( | ) | const |
True if embeds have been removed.
bool dpp::message::suppress_notifications | ( | ) | const |
True if the message will not trigger push and desktop notifications.
struct dpp::message::allowed_ref dpp::message::allowed_mentions |
std::vector<attachment> dpp::message::attachments |
any attached files
user dpp::message::author |
the author of this message (not guaranteed to be a valid user)
snowflake dpp::message::channel_id |
id of the channel the message was sent in
std::vector<dpp::component> dpp::message::components |
message components
std::string dpp::message::content |
contents of the message
time_t dpp::message::edited |
when this message was edited (may be 0 if never edited)
std::vector<embed> dpp::message::embeds |
Up to 10 dpp::embed objects
std::vector<std::string> dpp::message::filecontent |
File content to upload (raw binary)
std::vector<std::string> dpp::message::filename |
Name of file to upload (for use server-side in discord's url)
uint16_t dpp::message::flags |
Flags. Made of bits in dpp::message_flags
snowflake dpp::message::guild_id |
Optional: id of the guild the message was sent in
|
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.
struct dpp::message::message_interaction_struct dpp::message::interaction |
guild_member dpp::message::member |
Optional: member properties for this message's author
std::vector<channel> dpp::message::mention_channels |
Channels mentioned in the message. (Discord: not all types supported) Discord: Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include mention_channels at all. (includes ID, Guild ID, Type, Name)
bool dpp::message::mention_everyone |
whether this message mentions everyone
std::vector<snowflake> dpp::message::mention_roles |
roles specifically mentioned in this message (only IDs currently)
std::vector<std::pair<user, guild_member> > dpp::message::mentions |
users specifically mentioned in the message
struct dpp::message::message_ref dpp::message::message_reference |
std::string dpp::message::nonce |
Optional: used for validating a message was sent
class cluster* dpp::message::owner |
The cluster which created this message object.
bool dpp::message::pinned |
whether this message is pinned
std::vector<reaction> dpp::message::reactions |
Optional: reactions to the message
time_t dpp::message::sent |
when this message was sent
std::vector<sticker> dpp::message::stickers |
Stickers
bool dpp::message::tts |
whether this was a TTS message
message_type dpp::message::type |
Message type
snowflake dpp::message::webhook_id |
Optional: if the message is generated by a webhook, its id will be here otherwise the field will be 0