Skip to content

Interaction respond with file raises exception in cogs #410

Closed
@IbraGonzaII

Description

@IbraGonzaII

Summary

Interaction respond with file raises exception in cogs

Reproduction Steps

Create a simple slash command in a cog that responds with a file.

Observe the exception that is raised.

Minimal Reproducible Code

from discord.ext import commands
from discord.commands import slash_command, Option

from discord import File

class TestCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @slash_command(name='test', guild_ids=[], description="testing")
        async def test_file(self, ctx, world: Option(str, "Enter your name")):
            try:
                path = 'enter local file path'
                await ctx.respond(file=File(path))
            except Exception as e:
                logger.exception(e)

def setup(bot):
    bot.add_cog(TestCog(bot))

Expected Results

File should be uploaded.

Actual Results

An exception was raised:

Traceback (most recent call last):
  File "/code/cogs/Dominance.py", line 36, in sl_dominance_cmd
    await ctx.respond(file=File(path))
  File "/usr/local/lib/python3.8/site-packages/discord/interactions.py", line 574, in send_message
    raise InvalidArgument('cannot pass both file and files parameter to send()')
discord.errors.InvalidArgument: cannot pass both file and files parameter to send()

Seems to be raised here:
https://github.com/Pycord-Development/pycord/blob/master/discord/interactions.py#L561

Possibly, file is not properly passed from:

def respond(self):

Intents

members only

System Information

  • Python v3.8.12-final
  • py-cord v2.0.0-alpha
    • py-cord pkg_resources: v2.0.0a4178+g6e2cb76c
  • aiohttp v3.7.4.post0
  • system info: Linux 5.10.0-9-amd64 Update README.rst #1 SMP Debian 5.10.70-1 (2021-09-30)

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

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions