From b77e4377ab3e47c0cd45b4dce900ca6a18be6956 Mon Sep 17 00:00:00 2001 From: Norberto A Date: Sun, 1 Nov 2020 21:54:38 +0000 Subject: [PATCH] Added support for sending simple messages & messages with RichEmbeds --- src/Classes/Message.lua | 31 +++++++++++++++++++++++++++++++ src/RoHook.lua | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Classes/Message.lua diff --git a/src/Classes/Message.lua b/src/Classes/Message.lua new file mode 100644 index 0000000..c961867 --- /dev/null +++ b/src/Classes/Message.lua @@ -0,0 +1,31 @@ +local Message = {} +Message.ClassName = "Message" +Message.__index = Message + +function Message.new(content) + assert(content, "Content cannot be nil.") + assert(string.len(content), "Content must not exceed 2000 characters.") + + local self = { + content = content + } + + setmetatable(self, Message) + + return self +end + +function Message:addEmbed(embed) + assert(embed, "Embed cannot be nil.") + assert(embed.ClassName =="RichEmbed", "embed must be of type RichEmbed.") + + local embeds = self.embeds or {} + assert(#embeds <= 10, "Webhook messages can only contain 10 RichEmbeds.") + + table.insert(embeds, #embeds + 1, embed) + self.embeds = embeds + + return embed +end + +return Message \ No newline at end of file diff --git a/src/RoHook.lua b/src/RoHook.lua index 2207229..ce8c5e2 100644 --- a/src/RoHook.lua +++ b/src/RoHook.lua @@ -38,7 +38,8 @@ function RoHook:send(data) request.embeds = {data} elseif data.ClassName == "Message" then - print("Sending Message") + request.embeds = data.embeds or {} + request.content = data.content end local success, res = pcall(function()