Updated functions: setTimestamp(), setAuthor() and addField()
This commit is contained in:
parent
d54bd84452
commit
a56857e9b3
|
@ -3,9 +3,6 @@ RichEmbed.ClassName = "RichEmbed"
|
||||||
RichEmbed.__index = RichEmbed
|
RichEmbed.__index = RichEmbed
|
||||||
|
|
||||||
function RichEmbed.new(title, description)
|
function RichEmbed.new(title, description)
|
||||||
-- Title is limited to 256 characters
|
|
||||||
-- Description is limited to 2048 characters
|
|
||||||
|
|
||||||
if title then
|
if title then
|
||||||
assert(string.len(title) <= 256, "Title cannot be longer than 256 characters.")
|
assert(string.len(title) <= 256, "Title cannot be longer than 256 characters.")
|
||||||
end
|
end
|
||||||
|
@ -24,7 +21,8 @@ function RichEmbed.new(title, description)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function RichEmbed:setTimestmap()
|
function RichEmbed:setTimestamp()
|
||||||
|
self.timestamp = os.date("!%Y-%m-%dT%H:%M:%SZ")
|
||||||
end
|
end
|
||||||
|
|
||||||
function RichEmbed:setColor()
|
function RichEmbed:setColor()
|
||||||
|
@ -40,25 +38,27 @@ end
|
||||||
function RichEmbed:setThumbnail()
|
function RichEmbed:setThumbnail()
|
||||||
end
|
end
|
||||||
|
|
||||||
function RichEmbed:setAuthor()
|
function RichEmbed:setAuthor(name, url, iconUrl)
|
||||||
-- author.name is limited to 256 characters
|
-- author.name is limited to 256 characters
|
||||||
end
|
|
||||||
|
|
||||||
function RichEmbed:addField(name, value, inline)
|
|
||||||
-- 25 fields at most
|
|
||||||
-- feld.name is limited to 256 characters
|
|
||||||
-- field.value is limited to 1024
|
|
||||||
|
|
||||||
if name then
|
if name then
|
||||||
assert(string.len(name) <= 256, "Name cannot be longer than 256 characters.")
|
assert(string.len(name) <= 256, "Name cannot be longer than 256 characters.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if value then
|
local author = self.author or {
|
||||||
assert(string.len(value) <= 1024, "Value cannot be longer than 1024 characters.")
|
name = name,
|
||||||
|
url = url,
|
||||||
|
icon_url = iconUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
self.author = author
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function RichEmbed:addField(name, value, inline)
|
||||||
|
assert(name and value, "Name and Value cannot be nil.")
|
||||||
|
assert(string.len(name) <= 256, "Name cannot be longer than 256 characters.")
|
||||||
|
assert(string.len(value) <= 1024, "Value cannot be longer than 1024 characters.")
|
||||||
|
|
||||||
local fields = self.fields or {}
|
local fields = self.fields or {}
|
||||||
print(#fields)
|
|
||||||
assert(#fields + 1 <= 25, "RichEmbed cannot contain more than 25 fields.")
|
assert(#fields + 1 <= 25, "RichEmbed cannot contain more than 25 fields.")
|
||||||
|
|
||||||
local field = {
|
local field = {
|
||||||
|
|
Reference in New Issue