Primary Interface
The following documents the main interaction class
- class levelling.Level(bot, *, cache: Optional[levelling.abc.Cache] = None, datastore: Optional[levelling.abc.Datastore] = None, options: Optional[levelling.options.Options] = None)
The main interaction point for the discord.ext.levelling package
- __init__(bot, *, cache: Optional[levelling.abc.Cache] = None, datastore: Optional[levelling.abc.Datastore] = None, options: Optional[levelling.options.Options] = None)
- Parameters
bot (commands.Bot) – The instance of the bot to use internally
cache (Cache) – An instance of a class implementing the
Cache
interface Protocoldatastore (Datastore) – An instance of a class implementing the
Datastore
interface Protocoloptions (Options) – An instance of the
Options
dataclass to show the options to support
- get_level_from_xp(xp: int) int
Given a member, extract there level from the amount of xp they currently have
- Parameters
xp (int) – The xp amount to get a level for
- Returns
The LevellingMember’s level
- Return type
int
- get_level_xp_amount(level: int) int
Returns the amount of xp required for the next level
- Parameters
level (int) – The members current level
- Returns
Required xp for the next level
- Return type
int
- get_remaining_xp(current_level: int, xp: int) int
Calculates the required amount of xp left to achieve the next level from the current level
- Parameters
current_level (int) – The Members current level
xp (int) – The members current xp
- Returns
The amount of xp required to get to the next level
- Return type
int
- async leaderboard(guild_id: Optional[int] = None) List[levelling.dataclass.LevellingMember]
Returns a list of members sorted by level.
- Parameters
guild_id (int) – The guild to work with
- Returns
The sorted list of members
- Return type
List[LevellingMember]
- async propagate(message: discord.message.Message) Optional[levelling.payloads.LevelUpPayload]
Call me in
on_message
!- Parameters
message (discord.Message) – The message to propagate
- Returns
This is returned if the member levelled up this message
- Return type
Optional[LevelUpPayload]