Reqn Discord Webhook <none> Variable

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Peezzied

New Member
Feb 28, 2022
3
0
1
24
I used reqn addon and tried to do a new project with the involvement of discord webhooks.
code_language.skript:
command /post:test:
    trigger:
        set {_custom} to "something"
        wait a second
        send a "post" request to "https://discord.com/api/webhooks/token" with the body "content=Test this var: %{_custom}%&" and the headers "content-type: application/x-www-form-urlencoded"
        set {_r} to the last http response
        set {_c} to {_r}'s status code
        set {_b} to {_r}'s body
        broadcast {_b}, {_c}
(The webhook URL is just a dummy for this post)

The code seems fine. But when the post request is sent, the webhook's content/message is Test this var: <none>
Why does the {_custom} variable is <none>. Though it is set to "something"?
 
Hey @Peezzied,

You should probably send the request body in a JSON formatted string. For example, you can try:
Code:
send a "post" request to "https://discord.com/api/webhooks/channelId/webhookToken" with the header "Content-Type: application/json" and the body "{""content"":""foobar""}"
 
Status
Not open for further replies.