How Can i Fix this with Nextcord

Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x00000164BCDF7850>:
Traceback (most recent call last):
  File "C:\Users\M3C4V1C4\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\nextcord\application_command.py", line 918, in invoke_callback_with_hooks     
    await self(interaction, *args, **kwargs)
  File "C:\Users\M3C4V1C4\Desktop\botina\main.py", line 62, in mute
    await interaction.response.send(f'{member.mention} Je mutiran/a.')
          ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'InteractionResponse' object has no attribute 'send'

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: AttributeError: 'InteractionResponse' object has no attribute 'send'

I tried to reinstall nextcord but does working…

  • The error on it’s own does not help here, please provide a code snippet

    – 

  • @Karo i upload code

    – 

  • No, you gave an error message

    – 

Based on the documentation, it looks like the right method to do so is using send_message

The new line of code:

await interaction.response.send_message(f'{member.mention} Je mutiran/a.')

async def mute(interaction:discord.Interaction)

And in the last line change:
await interaction.response.send(f'{member.mention} Je unmutean/a posle {duration} sekundi.')
to:
await interaction.response.send_message(f'{member.mention} Je unmutean/a posle {duration} sekundi.')

async def mute(Interaction, member: nextcord.Member, duration: int = None):
    if not interaction.user.guild_permissions.mute_members:
        await interaction.response.send("Vi nemate dozvolu za mutiranje članova!", ephemeral=True)
        return
    muted_role = nextcord.utils.get(interaction.guild.roles, name="Muted")
    if not muted_role:
        muted_role = await interaction.guild.create_role(name="Muted")
        for channel in interaction.guild.channels:
            await channel.set_permissions(muted_role, send_messages=False)
    await member.add_roles(muted_role)
    await interaction.response.send_message(f'{member.mention} Je mutiran/a.')
    if duration:
        if duration <= 0:
            await interaction.response.send("Vreme trajanja mutea ne može biti manje od 0.")
            return
        await asyncio.sleep(duration)
        await member.remove_roles(muted_role)
        await interaction.response.send(f'{member.mention} Je unmutean/a posle {duration} sekundi.')

Here is the full code of mute

Leave a Comment