summaryrefslogtreecommitdiff
path: root/src/discord/discord.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-06-09 01:48:24 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-06-09 01:48:24 -0400
commit49ff9a249e4fbc6354810fb56a7488deeacd8cd2 (patch)
tree4604023b0543cd78bd94f9bcfb9c5334616efb1f /src/discord/discord.cpp
parentd7177cac979a376dd7ea6dd46f5c5edbb68a06d8 (diff)
downloadabaddon-portaudio-49ff9a249e4fbc6354810fb56a7488deeacd8cd2.tar.gz
abaddon-portaudio-49ff9a249e4fbc6354810fb56a7488deeacd8cd2.zip
remove temp attachment files when theyre actually done being uploaded
Diffstat (limited to 'src/discord/discord.cpp')
-rw-r--r--src/discord/discord.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp
index 151d88c..ffc1d4d 100644
--- a/src/discord/discord.cpp
+++ b/src/discord/discord.cpp
@@ -318,6 +318,10 @@ bool DiscordClient::HasGuildPermission(Snowflake user_id, Snowflake guild_id, Pe
return (base & perm) == perm;
}
+bool DiscordClient::HasSelfChannelPermission(Snowflake channel_id, Permission perm) const {
+ return HasChannelPermission(m_user_data.ID, channel_id, perm);
+}
+
bool DiscordClient::HasAnyChannelPermission(Snowflake user_id, Snowflake channel_id, Permission perm) const {
const auto channel = m_store.GetChannel(channel_id);
if (!channel.has_value() || !channel->GuildID.has_value()) return false;
@@ -439,7 +443,13 @@ void DiscordClient::SendChatMessageAttachments(const std::string &content, const
const auto field_name = "files[" + std::to_string(i) + "]";
req.add_file(field_name, attachment_paths.at(i), "unknown.png");
}
- m_http.Execute(std::move(req), sigc::bind<0>(sigc::mem_fun(*this, &DiscordClient::ChatMessageCallback), nonce));
+ m_http.Execute(std::move(req), [this, attachment_paths, nonce](const http::response_type &res) {
+ for (const auto &path : attachment_paths) {
+ std::error_code ec;
+ std::filesystem::remove(path, ec);
+ }
+ ChatMessageCallback(nonce, res);
+ });
}
void DiscordClient::SendChatMessageText(const std::string &content, Snowflake channel, Snowflake referenced_message) {