so, I am trying to implement load and unload functions which will only be accessible by owner and if a user tries to use those functions, permission denied message will appear, but it is happening for both user and owner and also the function is not getting unloaded.. this is happening after I have made say_error function, load and unload functions were working perfectly fine for owner before making say_error
#Bot Permission Error
1 messages · Page 1 of 1 (latest)
import discord
from discord.ext import commands
async def is_owner(ctx):
return ctx.author.id == ctx.guild.owner.id
class Miscellaneous(commands.Cog):
@commands.command ()
async def joined(self, ctx, who : discord.Member):
await ctx.send(f"```{ctx.author.display_name} joined at {who.joined_at}```") # display_name displays the server name of the author not their tag name
* -------------------------------------------------------------------
@commands.command()
@commands.check(is_owner)
async def load(self, ctx, cog: str):
await self.bot.load_extension(f"cogs.{cog.lower()}")
* -------------------------------------------------------------------
@commands.command()
@commands.check(is_owner)
async def unload(self, ctx, cog: str):
await self.bot.unload_extension(f"cogs.{cog.lower()}")
* -------------------------------------------------------------------
# Error handling for load and unload
@load.error
@unload.error
async def say_error(self, ctx, error):
if isinstance(error, commands.CommandError):
await ctx.send(f"Permission Denied!")
* -------------------------------------------------------------------
async def setup(bot):
await bot.add_cog(Miscellaneous(bot))
This is owner error
This is user error
there is a specific decorator for checking if the command i biker is the owner of the bot
its @commands.is_owner()
this way is leaving your bot vulnerable because ur checking the server owner id
if you want to actually check this use @commands.is_guild_owner()
but for your use case, use is_owner
from your Miscellaneous class your also missing your __init__ function where you set the bot attribute