Nightbot Google Sheets Urlfetch

Hey guys! I’m currently trying to make a command for nightbot that fetches the first row of a Google sheet and displays it when the command is used. I was wondering if it is even possible to do with nightbot, judging by the lack of info when it comes to this. The current code that I have is this:

$(eval JSON.parse(decodeURIComponent(’$(querystring $(urlfetch json <

This is only a portion of the command. The link in there is a published plaintext file that outputs to JSON. I got the second portion of the command from an older forum post about this, but, nightbot doesn’t recognize the right row, and gives all sorts of errors when the command is attempted. This is the second portion of the code:

)))).feed.entry.filter(x=>x[gs$cell][col]==1).map(x=>x[gs$cell][$t]).join( | ).slice(0,400)||Error!`)

I’m reletively new to JavaScript, so, I’m not really sure how to troubleshoot this. If anyone has any ideas about this is would be greatly appreciated. -Maestro

Edit: Took out a link that leaked an email

Hey @probablymaestro!

What a big mess we have here, haha!
Okay, first issue I see is your first quote mark is breaking the code, you use when it’s either ', ", or ` that will work.

Next, after combining the two parts of the command (please send them in one block and after four spaces or between three backticks on both sides to make them clean, that makes our lives easier, this is why I ignored your post in the first place), there are way too many parenthesis:

$(eval JSON.parse(decodeURIComponent(`$(querystring $(urlfetch json LINK)))`)).feed.entry.filter(x=>x[` gs$cell`][` col`]==1).map(x=>x[` gs$cell`][` $t`]).join(` | `).slice(0,400)||` Error!`)

(`$(querystring $(urlfetch json link)))`), see three opening ones, four closing ones, this can’t work.

$(eval JSON.parse(decodeURIComponent(`$(querystring $(urlfetch json LINK))`)).feed.entry.filter(x=>x[` gs$cell`][` col`]==1).map(x=>x[` gs$cell`][` $t`]).join(` | `).slice(0,400)||` Error!`)

I also don’t understand the presence of the $(querystring) either since you want the first row.

$(eval JSON.parse($(urlfetch json LINK)).feed.entry.filter(x=>x[` gs$cell`][` col`]==1).map(x=>x[` gs$cell`][` $t`]).join(` | `).slice(0,400)||` Error!`)

Finally, it’s starting to look much cleaner and to make more sense.
Now, I don’t know where you got the second portion of the code (it’d be nice if you linked it), but it seems like it’s fetching the first column, and not the first row. Besides, it’d be useful for me to know what the first row contains as I’m not quite sure of what to fetch.

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