ZeusXBr Posted June 12, 2021 Share Posted June 12, 2021 (edited) I want to do this: Using webhook, something like this: -- created by zsenel local discordWebhookURL = "https://discord.com/api/webhooks/835103134270488596/FY5*********EXAMPLE************yKEaRsKJp4" function sendDiscordMessage(message) sendOptions = { formFields = { content = "Example:", username = "webhook - Example", embed = { description= "```Some user have typed \"help\" command.```", color= null, author= { name= "Webhook - Example" }, footer = { text = "I want to do this..." }, }, }, } fetchRemote ( discordWebhookURL, sendOptions, WebhookCallback ) end function WebhookCallback(responseData) outputDebugString("(Discord webhook callback): responseData: "..responseData) end function SendDiscordTestMessage(player, command, ...) local msg = table.concat({...}," ") -- for multiple words sendDiscordMessage(msg) end Return < Thats only a example do i want to do, any kind of help please? Edited June 12, 2021 by ZeusXBr Link to comment
Moderators Patrick Posted June 12, 2021 Moderators Share Posted June 12, 2021 This way works for me, to send data as JSON. function sendDiscordMessage(message) local data = { content = "Example:", username = "Webhook - Example", embeds = { { title = "Webhook - Example", description = "```Some user have typed \"help\" command.```", footer = { text = "I want to do this...", } } } } local jsonData = toJSON(data) jsonData = string.sub(jsonData, 3, #jsonData - 2) local sendOptions = { headers = { ["Content-Type"] = "application/json" }, postData = jsonData, } fetchRemote ( discordWebhookURL, sendOptions, WebhookCallback ) end 1 Link to comment
ZeusXBr Posted June 12, 2021 Author Share Posted June 12, 2021 11 hours ago, Patrick said: This way works for me, to send data as JSON. function sendDiscordMessage(message) local data = { content = "Example:", username = "Webhook - Example", embeds = { { title = "Webhook - Example", description = "```Some user have typed \"help\" command.```", footer = { text = "I want to do this...", } } } } local jsonData = toJSON(data) jsonData = string.sub(jsonData, 3, #jsonData - 2) local sendOptions = { headers = { ["Content-Type"] = "application/json" }, postData = jsonData, } fetchRemote ( discordWebhookURL, sendOptions, WebhookCallback ) end Thanks a lot. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now