Jump to content

Help | Webhook


ZeusXBr

Recommended Posts

function webhookEmbed(url, content, author, icon_url, description)
    local webhook_url = url
    sendOptions = {
        formFields = {
            content="```"..content.."```"
        },
        author = {
            "name": author,
            "icon_url": icon_url,
            "description": description,
        },
    }
    fetchRemote(webhook_url, sendOptions)
end

addEventHandler("onResourceStart", resourceRoot, function(res)
    resourceName = getResourdiscordName(resourceRoot)
    url = "WebhookLink"
    webhookEmbed(url, "Test", "Test", "https://link.jpg", "Test")

    outputDebugString("["..resourceName.."]: Resource started.", 3, 97, 235, 52)
end)

addEventHandler("onResourceStop", resourceRoot, function(res)
    resourceName = getResourceName(resourceRoot)
    outputDebugString("["..resourceName.."]: Resource stopped.", 3, 255, 0, 0)
end)

But, the webhook dont works, any help?

Link to comment
  • Moderators

Yeah, and there are some other problems.

author subtable's syntax is incorrect, you have to use = instead of : and put index names inside [ ] (or use them withouth " ")
- fetchRemote's syntax is incorrect, a callback function is required

Don't forget to use /debugscript 3

Here is a tutorial of how to send Discord messages trough webhook: 

 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...