|
19 | 19 | class Owner(commands.Cog, name="owner"): |
20 | 20 | def __init__(self, bot): |
21 | 21 | self.bot = bot |
| 22 | + |
| 23 | + @commands.hybrid_command( |
| 24 | + name="load", |
| 25 | + description="Load a cog", |
| 26 | + ) |
| 27 | + @checks.is_owner() |
| 28 | + async def load(self, ctx, cog: str): |
| 29 | + """ |
| 30 | + The bot will load the given cog. |
| 31 | +
|
| 32 | + :param context: The hybrid command context. |
| 33 | + :param cog: The cog to be loaded. |
| 34 | + """ |
| 35 | + try: |
| 36 | + await self.bot.load_extension(f"cogs.{cog}") |
| 37 | + except Exception as e: |
| 38 | + embed=discord.Embed(title="load", description=f"Could not load the `{cog}` cog.") |
| 39 | + await ctx.send(embed=embed) |
| 40 | + return |
| 41 | + embed=discord.Embed(title="Load", description=f"Successfully loaded the `{cog}` cog.") |
| 42 | + await ctx.send(embed=embed) |
| 43 | + |
| 44 | + |
| 45 | + @commands.hybrid_command( |
| 46 | + name="unload", |
| 47 | + description="Unloads a cog.", |
| 48 | + ) |
| 49 | + @checks.is_owner() |
| 50 | + async def unload(self, ctx, cog: str): |
| 51 | + """ |
| 52 | + The bot will unload the given cog. |
| 53 | +
|
| 54 | + :param context: The hybrid command context. |
| 55 | + :param cog: The cog to be unloaded. |
| 56 | + """ |
| 57 | + try: |
| 58 | + await self.bot.unload_extension(f"cogs.{cog}") |
| 59 | + except Exception as e: |
| 60 | + embed=discord.Embed(title="Unload", description=f"Could not unload the `{cog}` cog.") |
| 61 | + await ctx.send(embed=embed) |
| 62 | + return |
| 63 | + embed=discord.Embed(title="Unload", description=f"Successfully loaded the `{cog}` cog.") |
| 64 | + await ctx.send(embed=embed) |
| 65 | + |
| 66 | + @commands.hybrid_command( |
| 67 | + name="reload", |
| 68 | + description="Reloads a cog.", |
| 69 | + ) |
| 70 | + @checks.is_owner() |
| 71 | + async def reload(self, ctx, cog: str): |
| 72 | + """ |
| 73 | + The bot will reload the given cog. |
| 74 | +
|
| 75 | + :param context: The hybrid command context. |
| 76 | + :param cog: The cog to be reloaded. |
| 77 | + """ |
| 78 | + try: |
| 79 | + await self.bot.unload_extension(f"cogs.{cog}") |
| 80 | + await self.bot.load_extension(f"cogs.{cog}") |
| 81 | + except Exception as e: |
| 82 | + embed=discord.Embed(title="Reload", description=f"Could not reload the `{cog}` cog.") |
| 83 | + await ctx.send(embed=embed) |
| 84 | + return |
| 85 | + embed=discord.Embed(title="Reload", description=f"Successfully reloaded the `{cog}` cog.") |
| 86 | + await ctx.send(embed=embed) |
22 | 87 |
|
23 | 88 | @commands.hybrid_command( |
24 | 89 | name="shutdown", |
|
0 commit comments