martincarrera / clash-royale-api

:crown: Clash Royale API that provides information about the game.
http://www.clashapi.xyz/
MIT License
354 stars 80 forks source link

Add Clash Royale Discord Bot #97

Closed HZooly closed 6 years ago

HZooly commented 6 years ago

Hey!

May I suggest this bot. It's using CR-API and ClashRoyale-API for getting images.

martincarrera commented 6 years ago

Of course! 😄

HZooly commented 6 years ago

@martincarrera thanks! I'll continue to integrate my bot using some endpoints of your API.

Remark: I did would to get idNames of chests, store them in a variables, and make random HTTP call for getting random image of chest. But it's impossible because /chests returns idNames like wood-chest-1. The part -1 is unavailable in images.

martincarrera commented 6 years ago

You are right.

Try this before getting the image: chest.replace(/-([0-9999])+/, '').

This way you remove the -1 part.

HZooly commented 6 years ago

Yep, right :-)

For being more accurate with random, I decided to store names like that:

let chestIDs = [
    "wooden-chest",
    "silver-chest",
    "golden-chest",
    "crown-chest",
    "magical-chest",
    "giant-chest",
    "super-magical-chest",
    "epic-chest",
    "legendary-chest",
    "lightning-chest",
    "fortune-chest",
    "kings-chest"
];

Because current API returns few times wood-chests (and some others).

Maybe implement a new endpoint for getting element randomly? For images & items.