61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
"""
|
|
Admin commands, that can be used from within the discord-client-chat
|
|
"""
|
|
|
|
# IMPORTS
|
|
import discord
|
|
from discord.ext import commands
|
|
|
|
# COG INIT
|
|
class Admin(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
# COG BODY
|
|
@commands.command(name="load", hidden=True)
|
|
@commands.is_owner()
|
|
async def load(self, ctx, *, cog: str):
|
|
"""
|
|
Used as 'load cogs.COGNAME'
|
|
"""
|
|
try:
|
|
self.bot.load_extension(cog)
|
|
except Exception as e:
|
|
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
|
|
else:
|
|
await ctx.send('**`SUCCESS`**')
|
|
|
|
|
|
@commands.command(name="unload", hidden=True)
|
|
@commands.is_owner()
|
|
async def unload(self, ctx, *, cog: str):
|
|
"""
|
|
Used as 'unload cogs.COGNAME'
|
|
"""
|
|
try:
|
|
self.bot.unload_extension(cog)
|
|
except Exception as e:
|
|
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
|
|
else:
|
|
await ctx.send('**`SUCCESS`**')
|
|
|
|
|
|
@commands.command(name="reload", hidden=True)
|
|
@commands.is_owner()
|
|
async def reload(self, ctx, *, cog: str):
|
|
"""
|
|
Used as 'reload cogs.COGNAME'
|
|
"""
|
|
try:
|
|
self.bot.unload_extension(cog)
|
|
self.bot.load_extension(cog)
|
|
except Exception as e:
|
|
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
|
|
else:
|
|
await ctx.send('**`SUCCESS`**')
|
|
|
|
|
|
# COG ENDING
|
|
def setup(bot):
|
|
bot.add_cog(Admin(bot))
|