Replace, error message in Nightbot

Asked Sep 1, 2020·4 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hello,

!subbed :
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&channelId=$(userid)&key=AIzaSyB361OxFYjoOALzvY-IOVBPtpTsVKFEUz8g

_subbed :

$(eval try{a=$(urlfetch json $(query));b=[];u=$(user);$(urlfetch https://pastebin.com/raw/7aSuvKnC))

in these commands
!subbed is alised to _subbed

These commands working for public enabled subscription channel.

but whenever it comes to private subscription channel. it throws error :
unexpected identifier

I want to show custom msg instead of “unexpected identifier”

Note : _subbed is aliased to !subbed

Thanks to @member

4 replies

Hey @Wooden Koala!

Please don't post more than one request for the same thing: (link expired)

That being said, I'm not sure why it doesn't work, only thing I could see being an issue is the content of your pastebin: two brackets are missing...

try{
a=$(urlfetch json $(query));
b=[];
u=`$(user)`;
if(!a.hasOwnProperty(`kind`)){
throw new Error(`${u} Set your subscriptions to public to get results: https://support.google.com/youtube/answer/7280190`);}
a.items.forEach(c=>b.push(c.snippet.title));
d=b.slice(0,3).join(`, `);
d?`${u} Your last subscriptions are: ${d}`:`${u} No subs found!`;}
catch(e){`Nightbot cannot output a response: `+e.message.slice(0,200);}

It would have been helpful if you linked the original post you got the code from.
Also, I don't think leaking your key is a good idea.

PS: it's @member

it throws an error :sunny: Unexpected identifier

After investigating (there are so many xloss with the same profile picture on YouTube, it would have been good to have your user ID), it looks like your key has expired and that's why you get the error.

hTWn4MCLFf.png

It is not about api key! It still throws an error

Thanks emily.