Dzardys Posted April 2, 2022 Share Posted April 2, 2022 Hi, I've been learning scripting recently and I'm struggling right now when trying to send a Discord message using a fetchRemote() function. I think I did nothing wrong when initializing the webhook, but still it doesn't send anything. Is there anyone, who might know the cause of this problem? function testWebhook() local url = "https://discordapp.com/api/webhooks/..." if url then sendOptions = { queueName = "default", connectionAttempts = 3, connectTimeout = 5000, formFields = { content = "test" }, } fetchRemote (url, sendOptions, function()end) else outputDebugString("Webhook not provided."); end end addEventHandler("onResourceStart", getResourceRootElement(), testWebhook) Thanks. Link to comment
Ayush Rathore Posted April 6, 2022 Share Posted April 6, 2022 (edited) Firstly place your resource in acl as admin (bad practice but to test just do it) <group name="Admin"> <object name="resource.dt"></object> </group> I have named my resource "dt" now in server.lua place this sendOptions = { queueName = "Discord Test Queue", connectionAttempts = 3, connectTimeout = 5000, formFields = { username= "your webhook bot name", avatar_url= "", content= "Hello World" } } function callback(data, info) iprint( "Discord Message Sent:" .. " success:" .. tostring(info.success) .. " statusCode:" .. tostring(info.statusCode) .. " data:" .. tostring(data)) end fetchRemote( "your webhook url", sendOptions, callback ) Enjoy Edited April 6, 2022 by Ayush Rathore 1 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