#How to detect this?
1 messages · Page 1 of 1 (latest)
you can do it for every command or a global check
@commandname.error
async def commandname_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
.
.
.
this would be a basic one
global check?
This would be for one command
with on_command_error it would check it global
If you use slash commands it should be on_application_command_error
k
still cant
i meant that the bot dont have permission
Challenge accepted
...
need help
Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Nope sorry
?
I can’t help
i've tried many ways but still cant solve the problem
What do you want it to be?
Ignoring the error?
no
Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
no
i want to handle it
This then
are you asking it to display the correct perms that it's missing?
just handle the "forbidden" error, i cant handle it
well then
(hang on a sec)
if isinstance(error,commands.MissingRole):
# put in what you want it to say
what does your command do?
maybe we can break down exactly what the perms it's missing
(also a tip)
before the if statements
do
async ...
print(error)
if isinstance....
maybe you can get the error that way
i already get the error Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
did you try this?
Also can you please send the code for the command
yes
@commands.slash_command(name="kick", description="Kicks a member from the server")
@commands.has_permissions(moderate_members=True)
async def kick(self, ctx, member: Option(discord.Member, required=True), reason: Option(str) = None):
if reason == None:
reason = "No reason provided"
if member in ctx.guild.members:
await ctx.guild.kick(member)
await ctx.respond(f'User {member.mention} has been kicked for {reason} by {ctx.author.mention}')
elif member.guild_permissions.moderate_members:
await ctx.respond("You can't do this, this person is a moderator!")
return
elif ctx.author == member:
await ctx.respond("You can't kick yourself, leave this server instead 😆")
return
elif member not in ctx.guild.members:
await ctx.respond("You can't kick a user that is not in this server!")
return
else:
pass
@kick.error
async def timeouterror(self, ctx, error):
if isinstance(error, MissingPermissions):
await ctx.respond(
"You can't do this! You need to have moderate members permissions!"
)
elif isinstance(error, discord.Forbidden):
await ctx.respond("The bot don't have permission to do this!\n You may need to check bot's permissions and place the bot's role on the top of the roles!")
else:
result = handle_error(error)
await ctx.respond(f"{result[0]}", embeds=result[1])
uhhh is it timeouterror?
i thought it was um
async def on_application_command_error(ctx,error):
no
my error is Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
maybe try using this??
it might work?
i have tried that, doesn't work
check if error.original exists, and if so rerun the error handler with ctx, error.original
?
sometimes, you may get the error type as discord.ApplicationCommandInvokeError
In these instances, the error has the attribute error.original which is the true error
yes
error.original = 403 Forbidden (error code: 50013): Missing Permissions
Then that means it’s missing permissions
the bot is missing permission
...