Update cogmanager.py
This commit is contained in:
parent
aa53d22b2b
commit
c87d97da28
1 changed files with 17 additions and 5 deletions
|
@ -1,14 +1,15 @@
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import os
|
import os
|
||||||
|
from config import ownerid
|
||||||
|
|
||||||
class CogManager(commands.Cog):
|
class CogManager(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.owner_id = int(os.getenv("ownerid"))
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def load(self, ctx, cog_name: str = None):
|
async def load(self, ctx, cog_name: str = None):
|
||||||
if ctx.author.id != self.owner_id:
|
if ctx.author.id != ownerid:
|
||||||
await ctx.send("You do not have permission to use this command.")
|
await ctx.send("You do not have permission to use this command.")
|
||||||
return
|
return
|
||||||
if cog_name is None:
|
if cog_name is None:
|
||||||
|
@ -22,7 +23,7 @@ class CogManager(commands.Cog):
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def unload(self, ctx, cog_name: str = None):
|
async def unload(self, ctx, cog_name: str = None):
|
||||||
if ctx.author.id != self.owner_id:
|
if ctx.author.id != ownerid:
|
||||||
await ctx.send("You do not have permission to use this command.")
|
await ctx.send("You do not have permission to use this command.")
|
||||||
return
|
return
|
||||||
if cog_name is None:
|
if cog_name is None:
|
||||||
|
@ -36,8 +37,7 @@ class CogManager(commands.Cog):
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def reload(self, ctx, cog_name: str = None):
|
async def reload(self, ctx, cog_name: str = None):
|
||||||
|
if ctx.author.id != ownerid:
|
||||||
if ctx.author.id != self.owner_id:
|
|
||||||
await ctx.send("You do not have permission to use this command.")
|
await ctx.send("You do not have permission to use this command.")
|
||||||
return
|
return
|
||||||
if cog_name is None:
|
if cog_name is None:
|
||||||
|
@ -50,5 +50,17 @@ class CogManager(commands.Cog):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send(f"Error reloading cog `{cog_name}`: {e}")
|
await ctx.send(f"Error reloading cog `{cog_name}`: {e}")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def listcogs(self, ctx):
|
||||||
|
"""Lists all currently loaded cogs in an embed."""
|
||||||
|
cogs = list(self.bot.cogs.keys())
|
||||||
|
if not cogs:
|
||||||
|
await ctx.send("No cogs are currently loaded.")
|
||||||
|
return
|
||||||
|
|
||||||
|
embed = discord.Embed(title="Loaded Cogs", description="Here is a list of all currently loaded cogs:")
|
||||||
|
embed.add_field(name="Cogs", value="\n".join(cogs), inline=False)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
await bot.add_cog(CogManager(bot))
|
await bot.add_cog(CogManager(bot))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue