ranking(), in any file of src/, and exported. It keeps a score per member, always in order, from one restart to the next, and per server unless you say otherwise.
src/levels/xp.ts
xp), and every message written in a server gives its author 10 points in the ranking of that server. add() starts from 0, and two messages at the same instant never lose a point, even on several processes.
To show who is first:
src/levels/top.ts
top(10) is the first ten, top(10, 10) the next ten. Each entry has its id, its score and its rank, from 1.
Everything a ranking declares and does is in the reference.
What a ranking does
An id is a text:
member.id, or anything else you rank (a team, a channel). A score is a number, with decimals if you want.
The lowest first
For a time, a number of tries, a golf score:order: 'lowest' puts the lowest score first.
src/race/fastest.ts
Per server, or for the whole bot
A ranking is per server by default, like a store: in a function that runs in a server,xp.add() and xp.top() work on the ranking of that server. Outside a server (a task, a private message), say which one with xp.in(guild). For one ranking across every server, declare it with scope: 'global'.
Where the scores are
Like a store, a ranking keeps its scores indata/<name>.json by default, one entry per member, and with storage: 'redis' in the Redis of REDIS_URL (see Storage), where it is a sorted set: xp:<server id>, dev:xp:<server id> in chapterjs dev.
In a file, top() and rankOf() put every score in order each time they are called: instant for thousands of members, slower for hundreds of thousands. Redis keeps the scores in order itself, whatever their number: for a large bot, use storage: 'redis'.
A ranking and a store can’t share a name: they would share a file, or a key. The second one is reported when the files load, and left out.
ranking() reference
Every field of a ranking, and what each call returns.
Storage
Keeping anything else, per server.