eval output is only the first word of a full string

I am working on a simple command that uses an external API to translate a phrase to pirate lingo.
The code:
$(eval text=$(urlfetch json https://api.funtranslations.com/translate/pirate.json?text=$(1)); translation=text.contents.translated)

An example of the JSON output from the API call (the URL fetched is https://api.funtranslations.com/translate/pirate.json?text=hello%20guys):

“success”: {
“total”: 1
“contents”: {
“translated”: “Ahoy guys”,
“text”: “hello guys”,
“translation”: “pirate”

For some reason the output is always the first word, not the entire string.
I am sure I made a mistake somewhere but I really cannot see it. Any help will be greatly appreciated :slight_smile:

$(1) passes only the first word in the input. Use $(querystring) instead.

EDIT: Gerhard :wink:

Hiya, replace $(1) with $(querystring).

$(1) will only be the first argument. https://docs.nightbot.tv/variables/arguments
$(querystring) is the full string (url-encoded) of arguments. https://docs.nightbot.tv/variables/querystring

edit: @RokettoJanpu too fast :smiley:

Thanks a lot - I did spot that like 5 minutes after posting. Thanks for the link to the doc - very much appreciated.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.