1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reqn Discord Webhook <none> Variable

Discussion in 'Skript' started by Peezzied, May 23, 2022.

Thread Status:
Not open for further replies.
  1. Peezzied

    Peezzied New Member

    Joined:
    Feb 28, 2022
    Messages:
    3
    Likes Received:
    0
    I used reqn addon and tried to do a new project with the involvement of discord webhooks.
    Code (Skript):
    1. command /post:test:
    2.     trigger:
    3.         set {_custom} to "something"
    4.         wait a second
    5.         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"
    6.         set {_r} to the last http response
    7.         set {_c} to {_r}'s status code
    8.         set {_b} to {_r}'s body
    9.         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"?
     
  2. Romitou

    Romitou New Member

    Joined:
    Jun 2, 2019
    Messages:
    8
    Likes Received:
    4
    Hey @Peezzied,

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

Share This Page

Loading...