Z
Z
Zero None2020-10-14 12:57:39
Python
Zero None, 2020-10-14 12:57:39

How to display an error through the bot if the user did not enter one of the arguments?

I have two arguments in command arg1 and arg2.
How to make it so that an error is displayed (in a video message) to the user if he did not enter / skipped one / all arguments?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-10-14
@ZERRITO

https://discordpy.readthedocs.io/en/stable/ext/com...

class MyBot(commands.Bot):
    async def on_command_error(self, ctx, e):
        if isinstance(e, commands.MissingRequiredArgument):
            await ctx.send(f"Недостаточно аргументов: {e.param} отсутствует")
        else:
            super().on_command_error(ctx, e)  # вызвываем оригинальный обработчик ошибок команд

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question