Added setWebhookUsername & setWebhookAvatar.
This commit is contained in:
parent
0d13bdab4b
commit
0301ad9a44
73
RoHook.lua
73
RoHook.lua
|
@ -21,39 +21,54 @@ end
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
-- Your webhook's URL
|
module.webhookConfig = {
|
||||||
module.webhookUrl = ""
|
webhookUrl = "https://canary.discordapp.com/api/webhooks/682537382519635974/VfS2r9dRsPW4Q-Ti4FPhnoeWY1KdeLeS6F4bTA2oqWzKrqqQQ2qII0UVJtouBnHml52P",
|
||||||
|
}
|
||||||
|
|
||||||
function module.newMessage(message)
|
function module.newMessage(message)
|
||||||
message = message
|
message = message
|
||||||
|
|
||||||
local content = {
|
local content = {
|
||||||
["content"] = message,
|
content = message,
|
||||||
["embeds"] = {}
|
embeds = {},
|
||||||
|
avatar_url = "",
|
||||||
|
username= "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function content.setWebhookUsername(name)
|
||||||
|
if(not name) then error("Name cannot be nil.") end
|
||||||
|
|
||||||
|
content.username = name
|
||||||
|
end
|
||||||
|
|
||||||
|
function content.setWebhookAvatar(url)
|
||||||
|
if(not url) then error("URL cannot be nil.") end
|
||||||
|
|
||||||
|
content.avatar_url = url
|
||||||
|
end
|
||||||
|
|
||||||
function content.addEmbed(title, description)
|
function content.addEmbed(title, description)
|
||||||
local embed = {
|
local embed = {
|
||||||
["title"] = title,
|
title = title,
|
||||||
["description"] = description,
|
description = description,
|
||||||
["color"] = 0,
|
color = 0,
|
||||||
["fields"] = {},
|
fields = {},
|
||||||
["thumbnail"] = {
|
thumbnail = {
|
||||||
["url" ]= ""
|
url= ""
|
||||||
},
|
},
|
||||||
["image"] = {
|
image= {
|
||||||
["url"] = ""
|
url = ""
|
||||||
},
|
},
|
||||||
["author"] = {
|
author = {
|
||||||
["name"] = "",
|
name = "",
|
||||||
["url"] = "",
|
url = "",
|
||||||
["icon_url"] = ""
|
icon_url = ""
|
||||||
},
|
},
|
||||||
["footer"] = {
|
footer = {
|
||||||
["text"] = "",
|
text = "",
|
||||||
["icon_url"] = ""
|
icon_url = ""
|
||||||
},
|
},
|
||||||
["timestamp"] = "" --"YYYY-MM-DDTHH:MM:SS.MSSZ"
|
timestamp = "" --"YYYY-MM-DDTHH:MM:SS.MSSZ"
|
||||||
}
|
}
|
||||||
|
|
||||||
table.insert(content.embeds, embed)
|
table.insert(content.embeds, embed)
|
||||||
|
@ -63,13 +78,13 @@ function module.newMessage(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
function embed.addField(name, value, inline)
|
function embed.addField(name, value, inline)
|
||||||
if(not name or not value) then error("Name and value can not be nil") end
|
if(not name or not value) then error("Name and value cannot be nil") end
|
||||||
inline = inline or false
|
inline = inline or false
|
||||||
|
|
||||||
local field = {
|
local field = {
|
||||||
["name"] = name,
|
name = name,
|
||||||
["value"] = value,
|
value = value,
|
||||||
["inline"] = inline
|
inline = inline
|
||||||
}
|
}
|
||||||
|
|
||||||
table.insert(embed.fields, field)
|
table.insert(embed.fields, field)
|
||||||
|
@ -77,26 +92,26 @@ function module.newMessage(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
function embed.setAuthor(name, url, icon_url)
|
function embed.setAuthor(name, url, icon_url)
|
||||||
if(not name and icon_url) then error("Name can not be nil") end
|
if(not name and icon_url) then error("Name cannot be nil") end
|
||||||
embed.author.name = name
|
embed.author.name = name
|
||||||
embed.author.url = url
|
embed.author.url = url
|
||||||
embed.author.icon_url = icon_url
|
embed.author.icon_url = icon_url
|
||||||
end
|
end
|
||||||
|
|
||||||
function embed.setThumbnail(url)
|
function embed.setThumbnail(url)
|
||||||
if(not url) then error("URL can not be nil") end
|
if(not url) then error("URL cannot be nil") end
|
||||||
|
|
||||||
embed.thumbnail.url = url
|
embed.thumbnail.url = url
|
||||||
end
|
end
|
||||||
|
|
||||||
function embed.setImage(url)
|
function embed.setImage(url)
|
||||||
if(not url) then error("URL can not be nil") end
|
if(not url) then error("URL cannot be nil") end
|
||||||
|
|
||||||
embed.image.url = url
|
embed.image.url = url
|
||||||
end
|
end
|
||||||
|
|
||||||
function embed.setFooter(text, url)
|
function embed.setFooter(text, url)
|
||||||
if(not text) then error("Text can not be nil!") end
|
if(not text) then error("Text cannot be nil!") end
|
||||||
|
|
||||||
embed.footer.text = text
|
embed.footer.text = text
|
||||||
embed.footer.icon_url = url
|
embed.footer.icon_url = url
|
||||||
|
@ -117,7 +132,7 @@ function module:send(content)
|
||||||
content = httpService:JSONEncode(content)
|
content = httpService:JSONEncode(content)
|
||||||
|
|
||||||
local success, data = pcall(function()
|
local success, data = pcall(function()
|
||||||
return httpService:PostAsync(module.webhookUrl, content)
|
return httpService:PostAsync(module.webhookConfig.webhookUrl, content)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return success, data
|
return success, data
|
||||||
|
|
Reference in New Issue