From cbc9db58f6ce8e2e36aef8ce6adec43aa64d3558 Mon Sep 17 00:00:00 2001 From: Sleepy Flower Date: Sun, 15 Oct 2023 15:17:33 -0400 Subject: [PATCH] add backwards compatible sendMessage --- include/sleepy_discord/client.h | 1 + include/sleepy_discord/message.h | 4 ++-- sleepy_discord/endpoints.cpp | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/sleepy_discord/client.h b/include/sleepy_discord/client.h index 177e07917..85dd5755d 100644 --- a/include/sleepy_discord/client.h +++ b/include/sleepy_discord/client.h @@ -216,6 +216,7 @@ namespace SleepyDiscord { } //maybe move this to message.h ObjectResponse sendMessage (Snowflake channelID, std::string message, std::vector embeds = {}, MessageReference replyingTo = {}, TTS tts = TTS::Default, RequestSettings> settings = {}); + ObjectResponse sendMessage (Snowflake channelID, std::string message, Embed embeds = Embed::Flag::INVALID_EMBED, MessageReference replyingTo = {}, TTS tts = TTS::Default, RequestSettings> settings = {}); ObjectResponse sendMessage (SendMessageParams params , RequestSettings> settings = {}); ObjectResponse uploadFile (Snowflake channelID, std::string fileLocation, std::string message, std::vector embeds = {}, MessageReference replyingTo = {}, RequestSettings> settings = {}); ObjectResponse uploadFile (SendMessageParams params, std::string fileLocation , RequestSettings> settings = {}); diff --git a/include/sleepy_discord/message.h b/include/sleepy_discord/message.h index f8eeef588..e773850b2 100644 --- a/include/sleepy_discord/message.h +++ b/include/sleepy_discord/message.h @@ -631,14 +631,14 @@ namespace SleepyDiscord { struct MessageParams : public DiscordObject { Snowflake channelID; std::string content = {}; - Embed embed = Embed::Flag::INVALID_EMBED; + std::vector embed; AllowedMentions allowedMentions; std::vector> components; JSONStructStart std::make_tuple( json::pair (&Type::content , "content" , json::OPTIONAL_FIELD), - json::pair (&Type::embed , "embed" , json::OPTIONAL_FIELD), + json::pair(&Type::embed , "embed" , json::OPTIONAL_FIELD), json::pair (&Type::allowedMentions, "allowed_mentions", json::OPTIONAL_FIELD), json::pair(&Type::components , "components" , json::OPTIONAL_FIELD) ); diff --git a/sleepy_discord/endpoints.cpp b/sleepy_discord/endpoints.cpp index 6b3746caa..9da8344fe 100644 --- a/sleepy_discord/endpoints.cpp +++ b/sleepy_discord/endpoints.cpp @@ -48,6 +48,10 @@ namespace SleepyDiscord { return ObjectResponse{ request(Post, path("channels/{channel.id}/messages", { channelID }), settings, createMessageBody(message, embeds, replyingTo, tts)) }; } + ObjectResponse BaseDiscordClient::sendMessage(Snowflake channelID, std::string message, Embed embed, MessageReference replyingTo, TTS tts, RequestSettings> settings) { + return ObjectResponse{ request(Post, path("channels/{channel.id}/messages", { channelID }), settings, createMessageBody(message, embed.empty() ? {} : { embed }, replyingTo, tts)) } + } + ObjectResponse BaseDiscordClient::sendMessage(SendMessageParams params, RequestSettings> settings) { return ObjectResponse{ request(Post, path("channels/{channel.id}/messages", { params.channelID }), settings, json::stringifyObj(params)) }; }