use correct error type for slash command errors

This commit is contained in:
LBlend committed 2023-04-20 03:40:53 +09:00
1 parent e4e282a45b
commit bacbb4f433
1 file changed
+9 -6
+9 -6
View File
@@ -138,26 +138,29 @@ class Errors(commands.Cog):
error (app_commands.AppCommandError): Eror context object
"""
# TODO: add support for defered interactions
# Log command usage, just in case
await self.on_app_command_completion(interaction, interaction.command)
if isinstance(error, commands.BotMissingPermissions):
if isinstance(error, app_commands.BotMissingPermissions):
permissions = ', '.join(error.missing_perms)
embed = embed_templates.error_warning(interaction, text='Jeg mangler følgende tillatelser:\n\n' +
f'```\n{permissions}\n```')
return await interaction.response.send_message(embed=embed)
elif isinstance(error, commands.MissingPermissions):
elif isinstance(error, app_commands.MissingPermissions):
permissions = ', '.join(error.missing_perms)
embed = embed_templates.error_warning(interaction, text='Du mangler følgende tillatelser\n\n' +
f'```\n{permissions}\n```')
return await interaction.response.send_message(embed=embed)
elif isinstance(error, commands.NotOwner):
embed = embed_templates.error_fatal(interaction, text='Bare boteieren kan gjøre dette')
return await interaction.response.send_message(embed=embed)
# TODO: figure this shit out. app_commands does not support this check
# elif isinstance(error, app_commands.NotOwner):
# embed = embed_templates.error_fatal(interaction, text='Bare boteieren kan gjøre dette')
# return await interaction.response.send_message(embed=embed)
elif isinstance(error, commands.CommandOnCooldown):
elif isinstance(error, app_commands.CommandOnCooldown):
embed = embed_templates.error_warning(interaction, text='Kommandoen har nettopp blitt brukt' +
f'Prøv igjen om `{error.retry_after:.1f}` sekunder.')
return await interaction.response.send_message(embed=embed)