Skip to main content

A leveling cog for discord bots

Project description

Dislevel

Making leveling easier for small as well as big bot

Installation

pip install dislevel

Usage

Making a simple bot with a db connection

from discord.ext import commands
from dislevel import increase_xp

bot = commands.Bot(command_prefix='/')


@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))


@bot.event
async def on_message(message):
    if not message.author.bot:
        await bot.process_commands(message)
        await increase_xp(message, bot, rate=5)

bot.load_extension('dislevel')

TOKEN = 'TOKEN_HERE'
bot.run(TOKEN)

For subclassed bot

from discord.ext import commands
from dislevel import increase_xp


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

    async def on_ready(self):
        print('We have logged in as {0.user}'.format(self.user))

    async def on_message(self, message):
        if not message.author.bot:
            self.process_commands(message)
            await increase_xp(message, bot, rate=5)
    

bot = MyCustomBot(command_prefix='/')

bot.load_extension('dislevel')

TOKEN = 'TOKEN_HERE'
bot.run(TOKEN)

And setup is done it will automatically configure database and store data in your database

By default it increases exp by 5 whenever increase_xp gets called but if you want a different rate then
await increase_xp(message, bot, rate=10)
Now exp will increase by 10

Run the bot and run the /rank command to see your rank

Commands

/rank - See your rank /leaderboard, /lb - See leaderboard /setbg <url> - Set your bg url /resetbg - Reset your bg url to default /levelrole - Check level roles /levelrole add <level> <role> - Add a level role /levelrole remove <level> - Remove a level role

Join Discord For any kind of help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dislevel-1.0.0.tar.gz (138.3 kB view hashes)

Uploaded Source

Built Distribution

dislevel-1.0.0-py3-none-any.whl (136.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page