Replace, error message in Nightbot

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 @RockettoJanpu

Hey @xloss!

Please don’t post more than one request for the same thing: Replace error message in Eval

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 @RokettoJanpu.

2 Likes

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

1 Like

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

Thanks emily.

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