12 #include "aegis/config.hpp"
13 #include "aegis/snowflake.hpp"
14 #include "aegis/shards/shard.hpp"
15 #include "aegis/rest/rest_reply.hpp"
16 #include "aegis/gateway/objects/attachment.hpp"
17 #include "aegis/gateway/objects/embed.hpp"
18 #include "aegis/gateway/objects/reaction.hpp"
19 #include "aegis/gateway/objects/user.hpp"
20 #include <nlohmann/json.hpp>
21 #include "aegis/futures.hpp"
26 struct edit_message_t;
37 AEGIS_DECL
void from_json(
const nlohmann::json& j, objects::message& m);
39 AEGIS_DECL
void to_json(nlohmann::json& j,
const objects::message& m);
49 ChannelNameChange = 4,
50 ChannelIconChange = 5,
51 ChannelPinnedMessage = 6,
81 from_json(nlohmann::json::parse(_json), *
this);
93 from_json(_json, *
this);
114 this->_channel = _channel;
124 this->_guild = _guild;
135 return _content == rhs;
141 return !(*
this == rhs);
147 return _content == rhs;
153 return !(*
this == rhs);
168 objects::message_type
type = Default;
260 return _guild !=
nullptr || _guild_id != 0;
269 return _channel !=
nullptr || _channel_id != 0;
272 #if !defined(AEGIS_DISABLE_ALL_CACHE)
279 return _user !=
nullptr || _author_id != 0;
295 #if !defined(AEGIS_DISABLE_ALL_CACHE)
358 std::tuple<snowflake, snowflake, snowflake, snowflake>
get_related_ids() const noexcept
360 return std::tuple<snowflake, snowflake, snowflake, snowflake>{ _channel_id, _guild_id, _message_id, _author_id };
364 friend AEGIS_DECL
void from_json(
const nlohmann::json& j,
objects::message& m);
365 friend AEGIS_DECL
void to_json(nlohmann::json& j,
const objects::message& m);
368 AEGIS_DECL
void populate_self();
370 std::string _content;
373 #if !defined(AEGIS_DISABLE_ALL_CACHE)
389 #if defined(AEGIS_HEADER_ONLY)
390 #include "aegis/gateway/objects/impl/message.cpp"
void set_content(const std::string &content) noexcept
Set the message's content.
Definition: message.hpp:211
snowflake get_channel_id() const noexcept
Get the Channel ID of the message.
Definition: message.hpp:229
bool operator!=(const char *rhs)
Comparison of message content.
Definition: message.hpp:151
std::string webhook_id
Definition: message.hpp:167
Stores creation time and extra data specific to Discord for entities.
Definition: snowflake.hpp:21
snowflake get_guild_id() const noexcept
Get the Guild ID of the message.
Definition: message.hpp:238
message(const std::string &content, aegis::channel *_channel, aegis::guild *_guild) noexcept
Constructor for the message object.
Definition: message.hpp:66
void set_channel(aegis::channel *_channel)
Definition: message.hpp:112
aegis::guild & get_guild()
Get a reference to the guild object this message was sent in.
Definition: message.cpp:28
bool is_dm() const noexcept
Whether message is a Direct Message.
Definition: message.hpp:175
Class for performing actions pertaining to a specified guild.
Definition: guild.hpp:159
aegis::channel & get_channel()
Get a reference to the channel object this message was sent in.
Definition: message.cpp:38
aegis::future< rest::rest_reply > create_reaction(const std::string &content)
Add a reaction to this message.
Definition: message.cpp:95
Primary class for managing a bot interface.
Definition: core.hpp:157
const std::string & get_content() const noexcept
Get a reference to the content of the message.
Definition: message.hpp:202
message(const std::string &_json, aegis::core *_core) noexcept
Constructor for the message object.
Definition: message.hpp:78
aegis::future< message > edit(const std::string &content)
Edit this message.
Definition: message.cpp:75
std::vector< objects::reaction > reactions
Definition: message.hpp:165
Definition: message.hpp:57
aegis::future< rest::rest_reply > delete_all_reactions()
Delete all reactions on this message (not available for DMs)
Definition: message.cpp:125
bool pinned
Definition: message.hpp:164
Class for performing actions pertaining to a specified channel.
Definition: channel.hpp:170
std::vector< objects::embed > embeds
Definition: message.hpp:163
objects::message_type type
Definition: message.hpp:168
Stores user-specific and guild-specific attributes of users.
Definition: user.hpp:37
snowflake nonce
Definition: message.hpp:166
message(aegis::core *_core) noexcept
Constructor for the message object.
Definition: message.hpp:101
bool is_webhook() const noexcept
Whether message is from a webhook.
Definition: message.hpp:193
aegis::future< rest::rest_reply > delete_own_reaction(const std::string &content)
Delete your reaction to this message.
Definition: message.cpp:105
bool has_guild() const noexcept
Definition: message.hpp:258
bool operator!=(const std::string &rhs)
Comparison of message content.
Definition: message.hpp:139
void set_guild(aegis::guild *_guild)
Definition: message.hpp:122
bool is_bot() const noexcept
Returns whether user is a bot.
Definition: user.hpp:41
bool mention_everyone
Definition: message.hpp:159
snowflake get_author_id() const noexcept
Get the Member ID of the author of the message.
Definition: message.hpp:247
std::string timestamp
Definition: message.hpp:156
future
Definition: futures.hpp:41
bool tts
Definition: message.hpp:158
std::string edited_timestamp
Definition: message.hpp:157
aegis::future< rest::rest_reply > delete_message()
Delete this message.
Definition: message.cpp:65
std::vector< objects::attachment > attachments
Definition: message.hpp:162
user author
Definition: message.hpp:169
bool is_bot() const noexcept
Whether message is from a bot.
Definition: message.hpp:184
bool has_channel() const noexcept
Whether the message has a valid channel set.
Definition: message.hpp:267
std::vector< snowflake > mentions
Definition: message.hpp:160
message(const nlohmann::json &_json, aegis::core *_core) noexcept
Constructor for the message object.
Definition: message.hpp:90
bool has_member() const noexcept
Whether the message has a valid member set.
Definition: message.hpp:277
snowflake get_id() const noexcept
Get the ID of the message.
Definition: message.hpp:220
aegis::user & get_user()
Get a reference to the user object this message was sent by.
Definition: message.cpp:49
bool operator==(const char *rhs)
Comparison of message content.
Definition: message.hpp:145
std::vector< snowflake > mention_roles
Definition: message.hpp:161
bool operator==(const std::string &rhs)
Comparison of message content.
Definition: message.hpp:133
aegis::future< rest::rest_reply > delete_user_reaction(const std::string &content, const snowflake member_id)
Delete other user reaction to this message (not available for DMs)
Definition: message.cpp:115
std::tuple< snowflake, snowflake, snowflake, snowflake > get_related_ids() const noexcept
Obtain the relevant snowflakes related to this message.
Definition: message.hpp:358
Definition: channel.hpp:57