Browse Source

fix(commands): discord.Attachment optional arg

This commit fixes an issue with the discord.Attachment argument raising the MissingRequiredArgument when used like this:
arg: discord.Attachment = None
when no attachment is provided to the command.
pull/10306/head
Martin 4 weeks ago
parent
commit
261612fad7
  1. 2
      discord/ext/commands/core.py

2
discord/ext/commands/core.py

@ -709,6 +709,8 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
# Try to detect Optional[discord.Attachment] or discord.Attachment special converter
if converter is discord.Attachment:
if attachments.is_empty():
return None if param.default is param.empty else param.default
try:
return next(attachments)
except StopIteration:

Loading…
Cancel
Save