How to shorten by specifying the number of characters

Asked Dec 2, 2021·8 replies·Last activity 4 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.

Sorry, I'm japanese, so my English is bad.

The command using $ (urlfetch url) answers too much, so I want to specify the number of characters and shorten it.

[now]
!stats $ (urlfetch url)

pleyer ID: [Level: 1,570 | Kills: 10,039 | Damage: 2,551,627 | Rank Score: 7,410 | Arena Rank Score: 5,823 | Season 6 Wins: 70 | Season 6 Kills: 2,156 | Season 7 Wins: 9 | Season 7 Kills: 1,788 | Season 8 Wins: 42 | Season 8 Kills: 2,023 | Season 10 Kills: 172]

[ideal]
!stats $ (urlfetch url)

pleyer ID: [Level: 1,570 | Kills: 10,039 | Damage: 2,551,627 | Rank Score: 7,410 | Arena Rank Score: 5,823 ...

8 replies

Hey @Lucky Ox!

That would be useful if you shared the code of the command.

Hi, @Polar Cat !
Thank you for your reply.

【add command】(about url : I can't reply as it is, so I'm converting "https" to "😀")

!commands add !apex @$(user): $(urlfetch 😀://api.2g.be/games/apex?q=$(querystring))

【use command】
!apex stats kiiti_san3 origin

【result】
kiiti_san3: [Level: 1,572 | Kills: 10,039 | Damage: 2,551,627 | Rank Score: 7,752 | Arena Rank Score: 5,858 | Season 6 Wins: 70 | Season 6 Kills: 2,156 | Season 7 Wins: 9 | Season 7 Kills: 1,788 | Season 8 Wins: 42 | Season 8 Kills: 2,023 | Season 10 Kills: 172]

【ideal result】
kiiti_san3: [Level: 1,572 | Kills: 10,039 | Damage: 2,551,627 | Rank Score: 7,752 | Arena Rank Score: 5,858 | ...

So if I understand you correctly, you just want to get rid of the Seasons data...

$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=$(querystring))`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>!e.includes(`Season`)); `$(user) — ${o.join(`|`)}`)

Also, if you wanted to only use it for your stats, here's how you could do it:

$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=stats%20kiiti_san3%20origin)`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>!e.includes(`Season`)); `$(user) — ${o.join(`|`)}`)

@Polar Cat

Oh my god, Emily 😍

I'm very happy! I'm so bigginer 😭

Lastly, please give me one more commands.

【ideal result】
kiiti_san3: [ Rank Score: 7,752 | Arena Rank Score: 5,858 | …

Furthermore, I want to remove , Level, Kills, and Damage.

This should do the job:

$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=$(querystring))`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>e.includes(`Rank`)); u=d[0].split(`:`).shift(); `$(user) — ${u}: ${o.join(`|`)}`)
$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=stats%20kiiti_san3%20origin)`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>e.includes(`Rank`)); u=d[0].split(`:`).shift(); `$(user) — ${u}: ${o.join(`|`)}`)

Thank you so much!!

I don't understand programming at all. And my English is bad. So it was really helpful!

How should i thank you. arigato 😍

@Polar Cat

Sorry to keep bothering you.

【ideal result】
kiiti_san3: Rank Score: 7,752 …

Furthermore, I want to remove Arena Rank Score.

You should have told me from the beginning that you only wanted the rank score...

$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=$(querystring))`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>e.includes(`Rank`)); u=d[0].split(`:`).shift(); `$(user) — ${u}: ${o[0]}`)
$(eval d=`$(urlfetch https://api.2g.be/games/apex?q=stats%20kiiti_san3%20origin)`.replace(/\[|\]/g,``).split(`|`); o=d.filter(e=>e.includes(`Rank`)); u=d[0].split(`:`).shift(); `$(user) — ${u}: ${o[0]}`)

Didn't find your answer? The community is on Discord.

Ask on Discord