xp-bot / v8

The official XP Discord Bot built with serenity.
https://xp-bot.net
3 stars 1 forks source link

Centralize xp management #97

Closed ConnysCode closed 1 year ago

ConnysCode commented 1 year ago

There has to be only one central function that manages xp logic and everything connected to it.

I've made this Experience in xp6 and 7 - this logic needs to be central and cannot be duplicated between many functions and handlers. It'll only cause issues in the longterm and will lead to unpredictable behaviour.

crnvl commented 1 year ago

We're currently using a centralized function for xp management in the xp-db-connector library. Which kind of benefits would a function that calls the lib function from the xp-bot project have?

ref: https://github.com/xp-bot/v8/blob/dev/xp-db-connector/src/guild_member.rs

ConnysCode commented 1 year ago

A centralized xp management function*.

A function that gets called from every event handler of interest, xp command, ... - that manages everything xp and level related from assigning roles over setting nicknames to actually setting xp.

Otherwise logic is duplicated multiple times for multiple types of xp and multiple commands and will have to get updated together all the time. This'll lead to inconsistent behaviour.

Refer to: https://github.com/xp-bot/XP-Discord-Bot/blob/XP-7/src/listeners/xpChangedListener.ts

ConnysCode commented 1 year ago

@angelsflyinhell Has this been implemented?

Levelup messages do not seem to work when playing games.

crnvl commented 1 year ago

Has not been implemented as level up messages get handled seperately anyways so implementing this for games won't be too much of a hassle