Added support for sending simple messages & messages with RichEmbeds

This commit is contained in:
Violet Millie 2020-11-01 21:54:38 +00:00
parent 7afef5cae8
commit b77e4377ab
2 changed files with 33 additions and 1 deletions

31
src/Classes/Message.lua Normal file
View File

@ -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

View File

@ -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()