diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-12-15 01:36:06 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-12-15 01:36:06 -0500 |
commit | af31402b7f1d9d118f07f0fd6554319dbd6b44b6 (patch) | |
tree | 309ef8ee1b4dc7e787193f4eaffa219f0b68213d /src/discord/discord.cpp | |
parent | 8324172a90752403edcec2203a2abb386046cc8f (diff) | |
parent | 4bce7b7523caa26023b1a2f5e02e6646ed29f5e0 (diff) | |
download | abaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.tar.gz abaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.zip |
Merge branch 'master' into theming
Diffstat (limited to 'src/discord/discord.cpp')
-rw-r--r-- | src/discord/discord.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index 0618e72..ac7e2f2 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -518,6 +518,7 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams ¶ms, c CreateMessageObject obj; obj.Content = params.Message; obj.Nonce = nonce; + obj.Attachments.emplace(); if (params.Silent) { obj.Flags |= MessageFlags::SUPPRESS_NOTIFICATIONS; } @@ -541,11 +542,16 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams ¶ms, c m_generic_dispatch.emit(); }); req.make_form(); - req.add_field("payload_json", nlohmann::json(obj).dump().c_str(), CURL_ZERO_TERMINATED); + for (size_t i = 0; i < params.Attachments.size(); i++) { + auto &attachment = params.Attachments.at(i); const auto field_name = "files[" + std::to_string(i) + "]"; - req.add_file(field_name, params.Attachments.at(i).File, params.Attachments.at(i).Filename); + req.add_file(field_name, attachment.File, attachment.Filename); + obj.Attachments->push_back({ static_cast<int>(i), attachment.Description }); } + + req.add_field("payload_json", nlohmann::json(obj).dump().c_str(), CURL_ZERO_TERMINATED); + m_http.Execute(std::move(req), [this, params, nonce, callback](const http::response_type &res) { for (const auto &attachment : params.Attachments) { if (attachment.Type == ChatSubmitParams::AttachmentType::PastedImage) { |