D++ (DPP)
C++ Discord API Bot Library
dpp::message Struct Reference

Represents messages sent and received on Discord. More...

#include <message.h>

+ Collaboration diagram for dpp::message:

Classes

struct  allowed_ref
 
struct  message_interaction_struct
 
struct  message_ref
 

Public Member Functions

 message ()
 Construct a new message object. More...
 
 ~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...
 
messageset_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...
 
messageset_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...
 
messagefill_from_json (nlohmann::json *j, cache_policy_t cp={cp_aggressive, cp_aggressive, cp_aggressive})
 
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 news channel via webhook. More...
 
bool supress_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 is_ephemeral () const
 True if ephemeral (visible only to issuer of a slash command) More...
 
bool is_loading () const
 True if loading. More...
 
messageadd_component (const component &c)
 Add a component (button) to message. More...
 
messageadd_embed (const embed &e)
 Add an embed to message. More...
 
messageset_flags (uint8_t f)
 Set the flags. More...
 
messageset_type (message_type t)
 Set the message type. More...
 
messageset_filename (const std::string &fn)
 Set the filename. More...
 
messageset_file_content (const std::string &fc)
 Set the file content. More...
 
messageset_content (const std::string &c)
 Set the message content. More...
 

Public Attributes

snowflake id
 
snowflake channel_id
 
snowflake guild_id
 
userauthor
 
guild_member member
 
std::string content
 
std::vector< dpp::componentcomponents
 
time_t sent
 
time_t edited
 
bool tts
 
bool mention_everyone
 
std::vector< snowflakementions
 
std::vector< snowflakemention_roles
 
std::vector< snowflakemention_channels
 
std::vector< attachmentattachments
 
std::vector< embedembeds
 
std::vector< reactionreactions
 
std::string nonce
 
bool pinned
 
snowflake webhook_id
 
uint8_t flags
 
std::vector< stickerstickers
 
std::string filename
 
std::string filecontent
 
uint8_t type
 
user self_author
 
struct dpp::message::message_ref message_reference
 
struct dpp::message::message_interaction_struct interaction
 
struct dpp::message::allowed_ref allowed_mentions
 

Detailed Description

Represents messages sent and received on Discord.

Constructor & Destructor Documentation

◆ message() [1/4]

dpp::message::message ( )

Construct a new message object.

◆ ~message()

dpp::message::~message ( )

Destroy the message object.

◆ message() [2/4]

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.

Parameters
channel_idThe channel to send the message to
contentThe content of the message
typeThe message type to create

◆ message() [3/4]

dpp::message::message ( snowflake  channel_id,
const embed _embed 
)

Construct a new message object with a channel and content.

Parameters
channel_idThe channel to send the message to
_embedAn embed to send

◆ message() [4/4]

dpp::message::message ( const std::string &  content,
message_type  type = mt_default 
)

Construct a new message object with content.

Parameters
contentThe content of the message
typeThe message type to create

Member Function Documentation

◆ add_component()

message & dpp::message::add_component ( const component c)

Add a component (button) to message.

Parameters
ccomponent to add
Returns
message& reference to self

◆ add_embed()

message & dpp::message::add_embed ( const embed e)

Add an embed to message.

Parameters
eembed to add
Returns
message& reference to self

◆ build_json()

std::string dpp::message::build_json ( bool  with_id = false,
bool  is_interaction_response = false 
) const

Build JSON from this object.

Parameters
with_idTrue if the ID is to be included in the built JSON
Returns
The JSON text of the message

◆ fill_from_json()

message & dpp::message::fill_from_json ( nlohmann::json j,
cache_policy_t  cp = {cp_aggressivecp_aggressivecp_aggressive} 
)

Fill this object from json.

Parameters
jJSON object to fill from
cpCache policy for user records, wether or not we cache users when a message is received
Returns
A reference to self

◆ is_crosspost()

bool dpp::message::is_crosspost ( ) const

Returns true if posted from other servers news channel via webhook.

Returns
true if posted from other server

◆ is_crossposted()

bool dpp::message::is_crossposted ( ) const

Returns true if the message was crossposted to other servers.

Returns
true if crossposted

◆ is_ephemeral()

bool dpp::message::is_ephemeral ( ) const

True if ephemeral (visible only to issuer of a slash command)

Returns
true if ephemeral

◆ is_loading()

bool dpp::message::is_loading ( ) const

True if loading.

Returns
true if loading

◆ is_source_message_deleted()

bool dpp::message::is_source_message_deleted ( ) const

True if source message was deleted.

Returns
true if source message deleted

◆ is_urgent()

bool dpp::message::is_urgent ( ) const

True if urgent.

Returns
true if urgent

◆ set_allowed_mentions()

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.

Parameters
_parse_userswether or not to parse users in the message content or embeds
_parse_roleswether or not to parse roles in the message content or embeds
_parse_everyonewether or not to parse everyone/here in the message content or embeds
_replied_userif set to true and this is a reply, then ping the user we reply to
userslist of user ids to allow pings for
roleslist of role ids to allow pings for
Returns
message& reference to self

◆ set_content()

message & dpp::message::set_content ( const std::string &  c)

Set the message content.

Parameters
cmessage content
Returns
message& reference to self

◆ set_file_content()

message & dpp::message::set_file_content ( const std::string &  fc)

Set the file content.

Parameters
fcraw file content contained in std::string
Returns
message& reference to self

◆ set_filename()

message & dpp::message::set_filename ( const std::string &  fn)

Set the filename.

Parameters
fnfilename
Returns
message& reference to self

◆ set_flags()

message & dpp::message::set_flags ( uint8_t  f)

Set the flags.

Parameters
fflags to set
Returns
message& reference to self

◆ set_reference()

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.

Parameters
_message_idmessage id to reply to
_guild_idguild id to reply to (optional)
_channel_idchannel id to reply to (optional)
fail_if_not_existstrue if the message send should fail if these values are invalid (optional)
Returns
message& reference to self

◆ set_type()

message & dpp::message::set_type ( message_type  t)

Set the message type.

Parameters
ttype to set
Returns
message& reference to self

◆ supress_embeds()

bool dpp::message::supress_embeds ( ) const

True if embeds have been removed.

Returns
true if embeds removed

Member Data Documentation

◆ allowed_mentions

struct dpp::message::allowed_ref dpp::message::allowed_mentions

◆ attachments

std::vector<attachment> dpp::message::attachments

any attached files

◆ author

user* dpp::message::author

the author of this message (not guaranteed to be a valid user)

◆ channel_id

snowflake dpp::message::channel_id

id of the channel the message was sent in

◆ components

std::vector<dpp::component> dpp::message::components

message components

◆ content

std::string dpp::message::content

contents of the message

◆ edited

time_t dpp::message::edited

when this message was edited (may be 0 if never edited)

◆ embeds

std::vector<embed> dpp::message::embeds

zero or more dpp::embed objects

◆ filecontent

std::string dpp::message::filecontent

File content to upload (raw binary)

◆ filename

std::string dpp::message::filename

Name of file to upload (for use server-side in discord's url)

◆ flags

uint8_t dpp::message::flags

Flags

◆ guild_id

snowflake dpp::message::guild_id

Optional: id of the guild the message was sent in

◆ id

snowflake dpp::message::id

id of the message

◆ interaction

struct dpp::message::message_interaction_struct dpp::message::interaction

◆ member

guild_member dpp::message::member

Optional: member properties for this message's author

◆ mention_channels

std::vector<snowflake> dpp::message::mention_channels

Optional: channels specifically mentioned in this message

◆ mention_everyone

bool dpp::message::mention_everyone

whether this message mentions everyone

◆ mention_roles

std::vector<snowflake> dpp::message::mention_roles

roles specifically mentioned in this message

◆ mentions

std::vector<snowflake> dpp::message::mentions

users specifically mentioned in the message

◆ message_reference

struct dpp::message::message_ref dpp::message::message_reference

◆ nonce

std::string dpp::message::nonce

Optional: used for validating a message was sent

◆ pinned

bool dpp::message::pinned

whether this message is pinned

◆ reactions

std::vector<reaction> dpp::message::reactions

Optional: reactions to the message

◆ self_author

user dpp::message::self_author

Self allocated user for caching being off

◆ sent

time_t dpp::message::sent

when this message was sent

◆ stickers

std::vector<sticker> dpp::message::stickers

Stickers

◆ tts

bool dpp::message::tts

whether this was a TTS message

◆ type

uint8_t dpp::message::type

Message type

◆ webhook_id

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

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