Skip to content

Argument parsing for attachment options not working in slash command groups in cogs #982

Closed
@SlimShadyIAm

Description

@SlimShadyIAm

Summary

I get an error when running a command which has an attachment option. This only happens in slash group commands and does not happen for regular slash commands. This happens on the latest commit.

Reproduction Steps

  1. Create a slash command group in a cog
  2. Create a command in the group that has an attachment argument
  3. Run the command and attach a file
  4. You'll get the following error:
Ignoring exception in on_interaction
Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/discord/commands/core.py", line 110, in wrapped
    ret = await coro(arg)
  File "/opt/venv/lib/python3.10/site-packages/discord/commands/core.py", line 756, in _invoke
    _data = ctx.interaction.data["resolved"]["attachments"][arg]
KeyError: 'resolved'

Minimal Reproducible Code

Basically the example provided by the repository but in a slash command group.

    tags = discord.SlashCommandGroup("tags", "Interact with tags", guild_ids=[12345])

    @tags.command(description="Add a new tag")
    async def add(self, ctx, name: Option(str, description="Name of the tag to add"), image: Option(discord.Attachment, description="Image to attach", required=False)) -> None:
        file = await image.to_file()
        await ctx.respond("Here's your file!", file=file)

Expected Results

Arguments parse correctly and the bot responds with whatever file was attached

Actual Results

The error I showed above is thrown.

Intents

Default + members + messages + presences

System Information

  • Python v3.10.0-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b4
  • aiohttp v3.7.4.post0
  • system info: Linux 5.10.47-linuxkit Update README.rst #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions