Skip to main content

A discord.py extension that automatically generates interaction help commands based on Dict.

Project description

discord.ext.help

A discord.py extension that automatically generates interaction help commands based on Dict.

Dependency

This library is not guaranteed to be compatible with the discord.py fork (Because the reactionmenu used in this library is probably dedicated to discord.py).

Also, for pycord, you can reproduce the behavior of this library by using discord.ext.pages.

How To Use

Install

pip install discord-ext-help

example

import discord
from discord import app_commands
from discord.ext import commands
from discord_ext_help import helpExtension, command_list, options
from reactionmenu import ViewMenu

command_list.cmdlist = [
    {
        "name": "/test",
        "id": None,
        "description": "this is a test command!",
        "args": [],
        "example": "https://media1.tenor.com/m/m1Tu9iU-zqQAAAAC/wumpus-discord.gif",
    },
    {
        "name": "/say",
        "id": None,
        "description": "The character entered in the argument is uttered!",
        "args": [
            {
                "name": "text",
                "description": None,
                "required": True,
            }
        ],
        "example": "https://media1.tenor.com/m/m1Tu9iU-zqQAAAAC/wumpus-discord.gif",
    },
]

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

@bot.event
async def setup_hook():
    # ↓ If you use the bot only within a particular guild ↓
    # await bot.tree.sync(guild=discord.Object(000000000000000000))
    # options.guild = 961559815191134229 # If you use the bot only within a particular guild

    # ↓ For use with a public Bot ↓
    await bot.tree.sync()

# ↓ If you use the bot only within a particular guild ↓
# @bot.tree.command(
#     name="help", description="show help", guild=discord.Object(serverId)
# )
# ↓ For use with a public Bot ↓
@bot.tree.command(
    name="help", description="show help"
)
@app_commands.choices(command=options.cmds)
async def help(interaction: discord.Interaction, command: str = None):
    await interaction.response.defer()
    res = await helpExtension.response(interaction, command)
    menu = res["resp"]

    if res["type"] == "menu":
        await menu.start()
        return
    await interaction.followup.send(embed=menu)

helpExtension.setup()
bot.run(token)

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_help-0.1.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

discord_ext_help-0.1.1-py3-none-any.whl (3.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