Skip to content

Commit

Permalink
add backwards compatible sendMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
yourWaifu committed Oct 15, 2023
1 parent a60187a commit cbc9db5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/sleepy_discord/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ namespace SleepyDiscord {
}
//maybe move this to message.h
ObjectResponse<Message > sendMessage (Snowflake<Channel> channelID, std::string message, std::vector<Embed> embeds = {}, MessageReference replyingTo = {}, TTS tts = TTS::Default, RequestSettings<ObjectResponse<Message>> settings = {});
ObjectResponse<Message > sendMessage (Snowflake<Channel> channelID, std::string message, Embed embeds = Embed::Flag::INVALID_EMBED, MessageReference replyingTo = {}, TTS tts = TTS::Default, RequestSettings<ObjectResponse<Message>> settings = {});
ObjectResponse<Message > sendMessage (SendMessageParams params , RequestSettings<ObjectResponse<Message>> settings = {});
ObjectResponse<Message > uploadFile (Snowflake<Channel> channelID, std::string fileLocation, std::string message, std::vector<Embed> embeds = {}, MessageReference replyingTo = {}, RequestSettings<ObjectResponse<Message>> settings = {});
ObjectResponse<Message > uploadFile (SendMessageParams params, std::string fileLocation , RequestSettings<ObjectResponse<Message>> settings = {});
Expand Down
4 changes: 2 additions & 2 deletions include/sleepy_discord/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,14 @@ namespace SleepyDiscord {
struct MessageParams : public DiscordObject {
Snowflake<Channel> channelID;
std::string content = {};
Embed embed = Embed::Flag::INVALID_EMBED;
std::vector<Embed> embed;
AllowedMentions allowedMentions;
std::vector<std::shared_ptr<BaseComponent>> components;

JSONStructStart
std::make_tuple(
json::pair (&Type::content , "content" , json::OPTIONAL_FIELD),
json::pair (&Type::embed , "embed" , json::OPTIONAL_FIELD),
json::pair<json::ContainerTypeHelper>(&Type::embed , "embed" , json::OPTIONAL_FIELD),
json::pair (&Type::allowedMentions, "allowed_mentions", json::OPTIONAL_FIELD),
json::pair<json::ContainerTypeHelper>(&Type::components , "components" , json::OPTIONAL_FIELD)
);
Expand Down
4 changes: 4 additions & 0 deletions sleepy_discord/endpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace SleepyDiscord {
return ObjectResponse<Message>{ request(Post, path("channels/{channel.id}/messages", { channelID }), settings, createMessageBody(message, embeds, replyingTo, tts)) };
}

ObjectResponse<Message> BaseDiscordClient::sendMessage(Snowflake<Channel> channelID, std::string message, Embed embed, MessageReference replyingTo, TTS tts, RequestSettings<ObjectResponse<Message>> settings) {
return ObjectResponse<Message>{ request(Post, path("channels/{channel.id}/messages", { channelID }), settings, createMessageBody(message, embed.empty() ? {} : { embed }, replyingTo, tts)) }
}

ObjectResponse<Message> BaseDiscordClient::sendMessage(SendMessageParams params, RequestSettings<ObjectResponse<Message>> settings) {
return ObjectResponse<Message>{ request(Post, path("channels/{channel.id}/messages", { params.channelID }), settings, json::stringifyObj(params)) };
}
Expand Down

0 comments on commit cbc9db5

Please sign in to comment.