Urlfetch inside pastebin

HI

I’m trying to make new Dynamic command thanks for preveus help i make it like this, but i’m having a litle proplom
i think that because i put urlfetch inside pastebin. is there any other way to do that ?

pastebin:

{

  "VALORANT": {

    "Rank": "VALORANT : 
Main  $(eval X=JSON.parse(`$(urlfetch https://api.kyroskoh.xyz/valorant/v1/mmr/EU/LAW/00000?show=combo&display=0 ) /
 Smurf  $(eval Z=JSON.parse(`$(urlfetch https://api.kyroskoh.xyz/valorant/v1/mmr/EU/LAW/999?show=combo&display=0 )"
  },
  "Overwatch 2": {
    "Rank": "Overwatch 2 : UnRanked (Placement 1 Win | 3 Lost)"
  }
}```

Command :

$(eval p = $(urlfetch json https://pastebin.com/raw/TjXtTvCY); s = []; Object.values(p).forEach(k => s.push(k.Rank)); ${s.join(', ')}`; t = '$(twitch $(channel) "{{status}}|{{game}}")'.split('|'); t[0] === 'offline' ? f : p[t[1]] ? p[t[1]].Rank: f;)

Hey @sawex!

As mentioned a couple times before, you can’t directly use Nightbot variables inside a Pastebin:

The solution to your problem is to call both $(urlfetch) in the command, and then call the Pastebin which will contain all the code.


First your command would look like this:

$(eval valorantMain = `$(urlfetch json https://api.kyroskoh.xyz/valorant/v1/mmr/EU/LAW/00000?show=combo&display=0)`; valorantSmurf = `$(urlfetch json https://api.kyroskoh.xyz/valorant/v1/mmr/EU/LAW/999?show=combo&display=0)`; t = '$(twitch $(channel) "{{status}}|{{game}}")'.split('|'); $(urlfetch https://pastebin.com/raw/XXXXXXXX))

And then your Pastebin like this:

const object = {
  "VALORANT": {
    "rank": `VALORANT : Main ${valorantMain} / Smurf ${valorantSmurf}`
  },
  "Overwatch 2": {
    "rank": "Overwatch 2 : UnRanked (Placement 1 Win | 3 Lost)"
  }
};

let s = [];
Object.values(object).forEach(k => s.push(k.rank));
const f = s.join(', ');

t[0] === 'offline' ? f : object[t[1]] ? object[t[1]].rank : f;
2 Likes

Thank you so much
very appreciate your work
this one my mistake because i don’t know why i didn’t notice it on the search

1 Like

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