Skip to main content

A discord.py extension for command name suggestion

Project description

A discord.py extension for command name suggestion

Documentation Status

Installation

# Windows
py -3 -m pip install --upgrade discord-ext-levenshtein

# Linux
python3 -m pip install --upgrade discord-ext-levenshtein

Usage

The extension will be enabled by creating levenshtein.Levenshtein when on_ready is called.

import os
import discord
from discord.ext import commands, levenshtein


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

    async def on_ready(self):
        print('Bot is ready')
        levenshtein.Levenshtein(self, max_length=3)

    async def on_command_suggest(self, ctx, suggested_commands):
        body = 'suggested commands: ' + ' '.join([f'`{command}`' for command in suggested_commands])
        await ctx.send(body)


bot = MyBot(command_prefix='+', intents=discord.Intents.all())


@bot.command()
async def ping(ctx):
    await ctx.send('pong')


@bot.group(invoke_without_command=True)
async def math(ctx):
    await ctx.send('this is a math cog')


@math.command()
async def add(ctx, a: int, b: int):
    await ctx.send(a + b)

bot.run(os.environ['BOT_TOKEN'])

For more usage, refer to the examples directory

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

discord-ext-levenshtein-0.3.0.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

discord_ext_levenshtein-0.3.0-py3-none-any.whl (4.9 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