'"Help" Command (Defectio.py, similar to discord.py)
I am using revolt.chat which has a similar API to discord.py called defectio.
This is the documentation for the default help command https://github.com/Darkflame72/defectio/blob/main/defectio/ext/commands/help.py#L920
I am looking for a way to write the help command into my utility cog(again executing this would be very similar to discord.py and using discord.py to answer would be fine as I can port it)
For reference, this is what my help command currently looks like, but it's nowhere near where I'd like it.
import defectio
from defectio.ext import commands
import random
import asyncio
import sys
import os
class MyHelpCommand(commands.MinimalHelpCommand):
def get_command_signature(self, command):
return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command)
async def send_bot_help(self, mapping):
for cog in mapping:
await self.get_destination().send(f'{cog.qualified_name}: {[command.name for command in mapping[cog]]}')
class Utility(commands.Cog):
def __init__(self, bot):
self._original_help_command = bot.help_command
bot.help_command = MyHelpCommand()
bot.help_command.cog = self
def cog_unload(self):
self.bot.help_command = self._original_help_command
def setup(bot: commands.Bot) -> None:
bot.add_cog(Utility(bot))
For styling reference, this is the styling I'd like. (Revolt supports table markdown)
await message.channel.send(r"""| Command/Module | Information | Usage |
|----------|----------|----------|
| $\color{cyan}\fbox{\textbf{\textsf{Utility}}}$ | | |
| .help | Use .help if you're confused on where to get started | .help (commands) |
| .commands | Check (a module's) commands. | .commands (module) |
| | | |
| $\color{red}\fbox{\textbf{\textsf{Administration}}}$ | |
| .r | Restart the bot.(Owner only) | .r | """)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|