Urlfetch inside pastebin

Asked Oct 23, 2022·2 replies·Last activity 3 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.

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;)

2 replies

Hey @Rustic Badger!

As mentioned a couple times (link expired) before, you can't directly use Nightbot variables inside a Pastebin:
/t/use-nightbot-variables-in-pastebin/1534636064776392835#m1534636077959352381

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:

javascript
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;

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