I am trying to handle errors for local commands of my discord bot and I get the following error discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: ‘Command’ object has no attribute ‘MissingRequiredArgument’ this only happens when I execute the code in repl and not in VSCode.I also tried the following
JavaScript
x
2
1
commands.errors.MissingRequiredArgument
2
JavaScript
1
9
1
@youtube.error
2
async def youtube_error(ctx,error):
3
if isinstance(error, commands.MissingRequiredArgument):
4
await ctx.send("Some text")
5
@tts.error
6
async def tts_error(ctx,error):
7
if isinstance(error, commands.MissingRequiredArgument):
8
await ctx.send("Some text")
9
Advertisement
Answer
You should send the complete code, but if I understood well, the problem is that in your file exists a Command
object called commands
, so that MissingRequiredArgument
is interpreted by repl as a Command object attribute, that obviously doesn’t exist.
There should be something like this in your code:
JavaScript
1
4
1
@Bot.command()
2
async def commands(ctx, *args):
3
4
Repl vs VS Code
Repl is for beginners/dummies, Visual Studio Code isn’t.The VS Code’s interpreter probably understood `commands` wasn’t referred to your command, so it doesn’t raise any error.