I’m very new to complex nightbot commands and I’m having trouble getting something to work that I know SHOULD work. What I want to do is have a !join command that will list the in-game user name based on current game being played.
example:
fortnite: fakename1
Based on cursory research, I know I should be able to have a pastebin set up with the list of games and usernames to add and use it as a JSON to look up the game and print the right username. But I cannot get it to work.
I have gotten $(twitch “{{game}}”) to work to use as the input, but I haven’t been able to incorporate that input into an $(eval) to look up in the pastebin.
You should be able to do a someVar = $(urlfetch json https://pastebin.com/raw/xxxxxxxxx); within the eval, then access the data you need through the someVar variable. The “json” portion of the urlfetch is important, as it parses the resulting message straight to a json object rather than a string, which bypasses the usual 400 character limit.
I’ve seen some of your previous posts on the topic (before I made this post) and tried to incorporate the logic from those, but I think my issue is that I know actual nothing about this. It seems like my current issue is I can define variables, but I don’t know what to do to make it execute. Here’s what I have so far:
$(eval game = ‘$(twitch vlamish {{game}})’; ID = $(urlfetch json https:// pastebin . com/raw/LUeiDFh9); )
the pastebin:
{“Overwatch 2”:“testname1”,
“Apex Legends”:“testname2”,
“World of Warcraft”,“testname3”}
Apologize for having to break the pastebin link, the site wouldn’t let me post with a link. So ideally someone would use the command and when I’m playing overwatch, the output would simply be “testname1”.