JuicyBot_Base/commands/admin.py

66 lines
2.2 KiB
Python

from discord.ext import commands
from config import cogs
import configloader
class Admin(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def cog_check(self, ctx):
return await ctx.bot.is_owner(ctx.author)
@commands.command(description='Shows existing Cogs',
usage=f'{configloader.__prefix__}cogs',
hidden=True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def cogs(self, ctx):
await ctx.send(cogs.__cogs__)
@commands.command(name='load',
description='Loads a Module',
usage=f'{configloader.__prefix__}load <cog>',
hidden=True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def load_cog(self, ctx, cog):
try:
self.bot.load_extension(f"commands.{cog}")
except Exception as err:
print(f"{cog} couldn't be loaded")
raise err
else:
await ctx.send(f'{cog} : Successfully loaded')
@commands.command(name='unload',
description='Unloads a Module',
usage=f'{configloader.__prefix__}unload <cog>',
hidden=True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def unload_cog(self, ctx, cog):
try:
self.bot.unload_extension(f"commands.{cog}")
except Exception as err:
print(f"{cog} : couldn't be unloaded")
raise err
else:
await ctx.send(f'{cog} : Successfully unloaded')
@commands.command(name='reload',
description='Reloads a Module',
usage=f'{configloader.__prefix__}reload <cog>',
hidden=True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def reload_cog(self, ctx, cog):
try:
self.bot.unload_extension(f"commands.{cog}")
self.bot.load_extension(f'commands.{cog}')
except Exception as err:
print(f"'{cog} : couldn't be reloaded")
raise err
else:
await ctx.send(f'{cog} : Successfully reloaded')
def setup(bot):
bot.add_cog(Admin(bot))