Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

discord python handle cogs

@commands.command(hidden=True)
async def load(self, ctx, *, module: str):
    """Loads a module."""
    try:
        await self.bot.load_extension(module)
    except commands.ExtensionError as e:
        await ctx.send(f'{e.__class__.__name__}: {e}')
    else:
        await ctx.send('N{OK HAND SIGN}')

@commands.command(hidden=True)
async def unload(self, ctx, *, module: str):
    """Unloads a module."""
    try:
        await self.bot.unload_extension(module)
    except commands.ExtensionError as e:
        await ctx.send(f'{e.__class__.__name__}: {e}')
    else:
        await ctx.send('N{OK HAND SIGN}')

@commands.group(name='reload', hidden=True, invoke_without_command=True)
async def _reload(self, ctx, *, module: str):
    """Reloads a module."""
    try:
        await self.bot.reload_extension(module)
    except commands.ExtensionError as e:
        await ctx.send(f'{e.__class__.__name__}: {e}')
    else:
        await ctx.send('N{OK HAND SIGN}')
 
PREVIOUS NEXT
Tagged: #discord #python #handle #cogs
ADD COMMENT
Topic
Name
7+2 =