Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

MenuDocs/Discord-Levelling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Levelling

A package built for discord.py developers who want to easily and seamlessly integrate a levelling system into their bots.

Key features

  • Easy database integration for any database system
  • Fully tested
  • Highly customizable
  • Plug & Play

Example usage

import os

import discord
from discord.ext import commands
from levelling import Level, LevelUpPayload


class Bot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.level = Level(self)

    async def on_ready(self):
        print(f"-----\nLogged in as: {self.user.name} : {self.user.id}\n-----")

    async def on_message(self, message):
        leveled_up = await self.level.propagate(message)
        if leveled_up:
            await self.on_level_up(leveled_up)

        await self.process_commands(message)

    async def on_level_up(self, payload: LevelUpPayload):
        # This is triggered when a LevellingMember levels up
        member = payload.guild.get_member(payload.member.id)
        embed = discord.Embed(
            title=f"`{member.display_name}` has leveled up to level `{payload.level}`!"
        )
        await payload.channel.send(embed=embed)


bot = Bot(command_prefix="!", intents=discord.Intents.all())


@bot.command()
async def leaderboard(ctx):
    leaderboard_members = await bot.level.leaderboard()
    desc = "\n".join(f"<@{m.id}> - level `{m.level}`" for m in leaderboard_members)

    await ctx.send(f"Here's our leaders!\n---\n\n{desc}")


if __name__ == "__main__":
    token = os.getenv("TOKEN")
    bot.run(token)

Documentation | Examples | Support

For documentation and examples, see here

Join the MenuDocs' discord server for support with this package!

or dm us on twitter!

About

A simple way to handle levelling within a discord.py bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages