Added setWebhookUsername & setWebhookAvatar.

This commit is contained in:
Norberto A 2020-02-29 16:40:32 +00:00 committed by GitHub
parent 0d13bdab4b
commit 0301ad9a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 29 deletions

View File

@ -21,39 +21,54 @@ end
local module = {}
-- Your webhook's URL
module.webhookUrl = ""
module.webhookConfig = {
webhookUrl = "https://canary.discordapp.com/api/webhooks/682537382519635974/VfS2r9dRsPW4Q-Ti4FPhnoeWY1KdeLeS6F4bTA2oqWzKrqqQQ2qII0UVJtouBnHml52P",
}
function module.newMessage(message)
message = message
local content = {
["content"] = message,
["embeds"] = {}
content = message,
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)
local embed = {
["title"] = title,
["description"] = description,
["color"] = 0,
["fields"] = {},
["thumbnail"] = {
["url" ]= ""
title = title,
description = description,
color = 0,
fields = {},
thumbnail = {
url= ""
},
["image"] = {
["url"] = ""
image= {
url = ""
},
["author"] = {
["name"] = "",
["url"] = "",
["icon_url"] = ""
author = {
name = "",
url = "",
icon_url = ""
},
["footer"] = {
["text"] = "",
["icon_url"] = ""
footer = {
text = "",
icon_url = ""
},
["timestamp"] = "" --"YYYY-MM-DDTHH:MM:SS.MSSZ"
timestamp = "" --"YYYY-MM-DDTHH:MM:SS.MSSZ"
}
table.insert(content.embeds, embed)
@ -67,9 +82,9 @@ function module.newMessage(message)
inline = inline or false
local field = {
["name"] = name,
["value"] = value,
["inline"] = inline
name = name,
value = value,
inline = inline
}
table.insert(embed.fields, field)
@ -117,7 +132,7 @@ function module:send(content)
content = httpService:JSONEncode(content)
local success, data = pcall(function()
return httpService:PostAsync(module.webhookUrl, content)
return httpService:PostAsync(module.webhookConfig.webhookUrl, content)
end)
return success, data