Implementing pastebin for a !pb and !wr command

Hi, I’m trying to setup a command for a list of PBs and WRs on multiple zombies map by doing !pb/!wr map name. But the message text limit is limiting me, tried to find anything on how to implement this into a pastebin, but that was to no luck.

This is what I have done atm
!commands update !pb $(eval M=‘$(1)’; if(M==‘soe’){ ‘19:39’} else if(M == ‘tg’){ ‘No leaderboard PB’} else if(M==‘de’){ ‘25:54’} else if(M==‘zns’){ ‘21:17’}else if(M==‘gk’){ ‘33:03’} else if(M==‘rev’){ ‘24:50’} else if(M==‘super’){ ‘2:18:41’} else if(M==‘dotn’){ ‘26:51’} else if(M==‘voyage’){ ‘37:57’} else { ‘Please pick a map with map name (eg soe)’ })

How could I implement this into a pastebin?

Create your Pastebin with the content in this format:

soe=19:39;
tg=No leaderboard PB;
de=25:54;
zns=21:17;
gk=33:03;
rev=24:50;
super=2:18:41;
dotn=26:51;
voyage=37:57;

And create your !pb command like this:

$(eval a='$(urlfetch https://pastebin.com/raw/XXXXXXXXXX)'.split(';').reduce((acc,l)=>{let[k,v]=l.split('=');if(k&&v)acc[k.trim()]=v.trim();return acc},{});m='$(1)'.toLowerCase();(m=='null') ? 'Please pick a map with map name (eg soe)' : (a[m] ? a[m] : 'No result found for ' + m))

I just get the response " No result found for xxxx"

Did you change the URL to your Pastebin one? Paste it here so we can check it.

https ://pastebin . com/raw/cmQ2Yxxy
Cannot include links in post, but this is what I used

Ok, I see the problem now. To fix it, we’re going to change the format of the pastebin to JSON like this:

{
  "cotd": "4:37 by Frothy Milkshake https://youtube.com/watch?v=uGjoveS5k9o",
  "moon": "8:59 by Frothy Milkshake https://youtube.com/watch?v=SqiYzTZZhPI",
  "tranzitt": "10:56 by Frothy Milkshake https://youtube.com/watch?v=aU1s0QyXJQg",
  "dierise": "4:43 by JettLag http://twitch.tv/videos/2375294602",
  "motd": "18:12 by J Dubs https://youtube.com/watch?v=7PZUr3PQYWg",
  "buried": "8:37 by Kyve https://youtube.com/watch?v=NeAeRGOJRmk",
  "origins": "35:34 by Dank Slushie https://youtube.com/watch?v=pazE9HHiP3g",
  "soe": "19:39 by Freckleston https://youtube.com/watch?v=-fOM2BPK-qE",
  "tg": "1:06 by IISteveII https://youtube.com/watch?v=NhZvOS3e0cw",
  "de": "25:54 by Freckleston https://youtube.com/watch?v=2oSfVSV_8LY",
  "zns": "20:34 by Invisible Hole https://youtube.com/watch?v=c6AKHVLiZ3Y",
  "gk": "31:27 by Invisible Hole https://youtube.com/watch?v=ATyk7vcLZWw",
  "rev": "23:04 by Sable https://youtube.com/watch?v=eJbF06wM0AQ",
  "bo3moon": "19:24 by x-MsHaKeS https://youtube.com/watch?v=iWKBchg4LDg",
  "bo3origins": "31:26 by CloudyMJ https://youtube.com/watch?v=IQCZ6LKP2GU",
  "bo3super": "2:13:04 by Seqn https://www.youtube.com/watch?v=vSp66Uevf0I",
  "ix": "33:23 by Kingman https://youtube.com/watch?v=ofjTVnkI0iA",
  "voyage": "37:57 by Freckleston https://youtube.com/watch?v=5rlPXPpdiSU",
  "botd": "43:46 by Wjorge https://youtube.com/watch?v=rlb0Ug7T6KE",
  "classified": "7:22 by Scrappy https://youtube.com/watch?v=G1n3mCobgXA",
  "dotn": "26:08 by Flindex https://youtube.com/watch?v=Mu92F63Ueuk",
  "ae": "25:22 by Flindex https://www.youtube.com/watch?v=QVojywtiA5s",
  "ao": "32:53 by Flindex https://youtube.com/watch?v=oGxh6KXz34o",
  "tag": "42:26 by Scrappy https://youtube.com/watch?v=yO0h2xhf8UI",
  "chaossuper": "2:01:07 by Garrett05 https://youtube.com/watch?v=BKvQDNFnvCE",
  "aethersuper": "2:02:20 by ScottSR https://youtube.com/watch?v=udIGXp9Ep4Y",
  "dm": "20:15 Tied by Valley172 and Remaster https://youtube.com/watch?v=vCvk2xE1RU0 https://youtube.com/watch?v=TAewGc0ARJE",
  "firebase": "20:50 by BDog102 https://youtube.com/watch?v=BR5rYnsezzU",
  "mauer": "23:20 by Remaster https://youtube.com/watch?v=znX06ACKTaE",
  "cwoutbreak": "20:17 by GamesWithFade https://youtube.com/watch?v=e0Eg2Qt3c-0",
  "cwoutbreak2": "16:19 by MasterSmexy https://youtube.com/watch?v=HzyEMsw0KB0",
  "forsaken": "12:25 by BDog102 https://youtube.com/watch?v=GPGXq3yAW-U",
  "terminus": "21:33 by Wydluvs https://youtube.com/watch?v=9yaIQqTUevI",
  "liberty": "13:17 by BDog102 https://youtube.com/watch?v=P6W9i-GsTCI",
  "cdm": "22:39 by Scrappy https://youtube.com/watch?v=vc0Y-aJRMto",
  "tomb": "26:08 by Carzeyy https://youtube.com/watch?v=m0g3XNPraO0",
  "sv": "22:31 by Remaster https://youtube.com/watch?v=T24a6achy6Y"
}

And the command like this:

$(eval a=$(urlfetch json https://pastebin.com/raw/XXXXX); m='$(1)'.toLowerCase(); m=='null' ? 'Please pick a map with map name (eg soe)' : (a[m] ? a[m] : 'No result found for ' + m))

With that, you shouldn’t have any more issues.

Now I get unexpected token:
Unexpected token ‘:’ [:1:9]

Create a new Pastebin because the previous format gets cached.

It worked, thanks for the help!
Gonna use this alot :slight_smile:

One final question, do I need to make a new pastebin every time I update something?

Lately, Pastebin has been caching the results and forces you to create new ones. You can try something like this to avoid the cache (I haven’t tested it for long to see if it works):

$(eval a=$(urlfetch json https://pastebin.com/raw/XXXXXX?t=$(eval Math.random())); m='$(1)'.toLowerCase(); m=='null' ? 'Please pick a map with map name (eg soe)' : (a[m] ? a[m] : 'No result found for ' + m))

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