mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
more optional + referencedata
This commit is contained in:
@@ -741,7 +741,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
|
||||
m_author->set_can_focus(false);
|
||||
m_author_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press));
|
||||
|
||||
if (data->WebhookID.IsValid()) {
|
||||
if (data->WebhookID.has_value()) {
|
||||
m_extra = Gtk::manage(new Gtk::Label);
|
||||
m_extra->get_style_context()->add_class("message-container-extra");
|
||||
m_extra->set_single_line_mode(true);
|
||||
|
||||
@@ -132,7 +132,7 @@ void DiscordClient::FetchMessagesInChannel(Snowflake id, std::function<void(cons
|
||||
m_store.SetMessage(msg.ID, msg);
|
||||
AddMessageToChannel(msg.ID, id);
|
||||
m_store.SetUser(msg.Author.ID, msg.Author);
|
||||
AddUserToGuild(msg.Author.ID, msg.GuildID);
|
||||
AddUserToGuild(msg.Author.ID, *msg.GuildID);
|
||||
ids.push_back(msg.ID);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void DiscordClient::FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake
|
||||
m_store.SetMessage(msg.ID, msg);
|
||||
AddMessageToChannel(msg.ID, channel_id);
|
||||
m_store.SetUser(msg.Author.ID, msg.Author);
|
||||
AddUserToGuild(msg.Author.ID, msg.GuildID);
|
||||
AddUserToGuild(msg.Author.ID, *msg.GuildID);
|
||||
ids.push_back(msg.ID);
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ void DiscordClient::HandleGatewayMessageCreate(const GatewayMessage &msg) {
|
||||
m_store.SetMessage(data.ID, data);
|
||||
AddMessageToChannel(data.ID, data.ChannelID);
|
||||
m_store.SetUser(data.Author.ID, data.Author);
|
||||
AddUserToGuild(data.Author.ID, data.GuildID);
|
||||
AddUserToGuild(data.Author.ID, *data.GuildID);
|
||||
m_signal_message_create.emit(data.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,18 @@ void from_json(const nlohmann::json &j, AttachmentData &m) {
|
||||
JS_ON("width", m.Width);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, MessageReferenceData &m) {
|
||||
JS_O("message_id", m.MessageID);
|
||||
JS_O("channel_id", m.ChannelID);
|
||||
JS_O("guild_id", m.GuildID);
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &j, const MessageReferenceData &m) {
|
||||
JS_IF("message_id", m.MessageID);
|
||||
JS_IF("channel_id", m.ChannelID);
|
||||
JS_IF("guild_id", m.GuildID);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, Message &m) {
|
||||
JS_D("id", m.ID);
|
||||
JS_D("channel_id", m.ChannelID);
|
||||
|
||||
@@ -21,6 +21,7 @@ enum class MessageType {
|
||||
CHANNEL_FOLLOW_ADD = 12,
|
||||
GUILD_DISCOVERY_DISQUALIFIED = 14,
|
||||
GUILD_DISCOVERY_REQUALIFIED = 15,
|
||||
INLINE_REPLY = 19,
|
||||
};
|
||||
|
||||
enum class MessageFlags {
|
||||
@@ -119,31 +120,40 @@ struct AttachmentData {
|
||||
friend void from_json(const nlohmann::json &j, AttachmentData &m);
|
||||
};
|
||||
|
||||
struct MessageReferenceData {
|
||||
std::optional<Snowflake> MessageID;
|
||||
std::optional<Snowflake> ChannelID;
|
||||
std::optional<Snowflake> GuildID;
|
||||
|
||||
friend void from_json(const nlohmann::json &j, MessageReferenceData &m);
|
||||
friend void to_json(nlohmann::json &j, const MessageReferenceData &m);
|
||||
};
|
||||
|
||||
struct Message {
|
||||
Snowflake ID; //
|
||||
Snowflake ChannelID; //
|
||||
Snowflake GuildID; // opt
|
||||
User Author; //
|
||||
// GuildMember Member; // opt
|
||||
std::string Content; //
|
||||
std::string Timestamp; //
|
||||
Snowflake ID;
|
||||
Snowflake ChannelID;
|
||||
std::optional<Snowflake> GuildID;
|
||||
User Author;
|
||||
// std::optional<GuildMember> Member;
|
||||
std::string Content;
|
||||
std::string Timestamp;
|
||||
std::string EditedTimestamp; // null
|
||||
bool IsTTS; //
|
||||
bool DoesMentionEveryone; //
|
||||
std::vector<User> Mentions; //
|
||||
// std::vector<Role> MentionRoles; //
|
||||
// std::vector<ChannelMentionData> MentionChannels; // opt
|
||||
std::vector<AttachmentData> Attachments; //
|
||||
std::vector<EmbedData> Embeds; //
|
||||
// std::vector<ReactionData> Reactions; // opt
|
||||
std::string Nonce; // opt
|
||||
bool IsPinned; //
|
||||
Snowflake WebhookID; // opt
|
||||
MessageType Type; //
|
||||
// MessageActivityData Activity; // opt
|
||||
// MessageApplicationData Application; // opt
|
||||
// MessageReferenceData MessageReference; // opt
|
||||
MessageFlags Flags = MessageFlags::NONE; // opt
|
||||
bool IsTTS;
|
||||
bool DoesMentionEveryone;
|
||||
std::vector<User> Mentions;
|
||||
// std::vector<Role> MentionRoles;
|
||||
// std::optional<std::vector<ChannelMentionData>> MentionChannels;
|
||||
std::vector<AttachmentData> Attachments;
|
||||
std::vector<EmbedData> Embeds;
|
||||
// std::optional<std::vector<ReactionData>> Reactions;
|
||||
std::optional<std::string> Nonce;
|
||||
bool IsPinned;
|
||||
std::optional<Snowflake> WebhookID;
|
||||
MessageType Type;
|
||||
// std::optional<MessageActivityData> Activity;
|
||||
// std::optional<MessageApplicationData> Application;
|
||||
std::optional<MessageReferenceData> MessageReference;
|
||||
std::optional<MessageFlags> Flags = MessageFlags::NONE;
|
||||
|
||||
friend void from_json(const nlohmann::json &j, Message &m);
|
||||
void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE
|
||||
|
||||
Reference in New Issue
Block a user