A discord.py extension for command name suggestion
Project description
A discord.py extension for command name suggestion
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
Built Distribution
File details
Details for the file discord-ext-levenshtein-0.3.0.tar.gz
.
File metadata
- Download URL: discord-ext-levenshtein-0.3.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bbbc2385dc438593c814694b44045c40cc367c9eb7bca7f474f734fb1ac9cea |
|
MD5 | ec727b27b746e2c09c7c537ce17840ba |
|
BLAKE2b-256 | 37bcfeaeedb42d5bf8f93a2fdc361d79bb1114f35d769f1a0703c1ca855d7c70 |
File details
Details for the file discord_ext_levenshtein-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: discord_ext_levenshtein-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dd7ad1ba97e5422a4d781f0adadd373bd277e8df4156e5bffaa13aa5025d4ca |
|
MD5 | 2972bbe454e7bee72005b16bc1d7133f |
|
BLAKE2b-256 | a382811c5025132fd4a63cc3d1af202c24a581b9c655e3b1390c7cba2287e965 |