почему не продолжается код disnake?

Рейтинг: 0Ответов: 1Опубликовано: 25.02.2023

есть команда /timeout [member] [duration] [reason]. Вот ошибка:

Ignoring exception in slash command 'таймаут':
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 732, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 1022, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/utils.py", line 600, in maybe_coroutine
    return await value
  File "<string>", line 865, in timeout
AttributeError: 'ApplicationCommandInteraction' object has no attribute 'edit_original_responce'

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

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1377, in process_application_commands
    await app_command.invoke(interaction)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 741, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ApplicationCommandInteraction' object has no attribute 'edit_original_responce'

вот код команды:

class Confirm(disnake.ui.View):
    def __init__(self):
        super().__init__(timeout=20.0)
        self.value: Optional[bool] = None
        
    @disnake.ui.button(style = disnake.ButtonStyle.primary, emoji = Icons.Sucess)
    async def confirm(self, button: disnake.ui.Button, interaction: disnake.CommandInteraction):
        self.value = True
        self.stop()
            
    @disnake.ui.button(style = disnake.ButtonStyle.red, emoji = Icons.Error)
    async def cancel(self, button: disnake.ui.Button, interaction: disnake.CommandInteraction):
        self.value = False
        self.stop()
            
@bot.slash_command(name = "таймаут", description = "Модерация / Лишить права слова участника")
@commands.has_permissions(kick_members = True)
async def timeout(interaction, member: disnake.Member = commands.Param(description="Участник"), duration: str = commands.Param(name = "длительность", description="Длительность (s | m | h | d)"), reason = commands.Param(description = "Причина")):
    g = json.load(open("Database/Guilds.json"))
    w = json.load(open("Database/Evil.json", "r"))
    if len(w[str(interaction.author.id)]) >= 4:
        await interaction.response.send_message(embed = disnake.Embed(title = Code.Unavailable, description = "Вы свершили 4 и более нарушений", color = 0xFF0000), ephemeral = True)
    else:
        if reason is None:
            reason = "Нет причины"
        if duration.endswith('d'):
            d = int(duration[:-1])
            h = 0
            min = 0
            sec = 0
            cd = f"{d} дней"
        if duration.endswith('h'):
            d = 0
            h = int(duration[:-1])
            min = 0
            sec = 0
            cd = f"{h} часов"
        if duration.endswith('m'):
            d = 0
            h = 0
            min = int(duration[:-1])
            sec = 0
            cd = f"{min} минут"
        if duration.endswith('s'):
            d = 0
            h = 0
            min = 0
            sec = int(duration[:-1])
            cd = f"{sec} секунд"
        if member.bot or member == interaction.author:
            error = disnake.Embed(description = f"{Icons.Error} Вы не можете исключить,  забанить или лишить права слова у самого себя, других модераторов или ботов", color = 0xFF0000)
            await interaction.response.send_message(embed = error, ephemeral = True)
        else:
            if d > 27 or h > 671 or min > 40319 or sec > 2419199:
                await interaction.response.send_message(embed = disnake.Embed(description = f"{Icons.Error} Не более 27 дней 23 часов 59 минут 59 секунд!", color = 0x2F3136), ephemeral = True)
            else:
                view = Confirm()
                confirm = disnake.Embed(title = ':bulb: Подтвердите', color = 0x2F3136)
                confirm.add_field(name='Нарушитель', value = f'└ {member.mention}')
                confirm.add_field(name='Модератор', value = f'└ {interaction.author.mention}')
                confirm.add_field(name='Причина', value = f'└ `{reason}`')
                
                await interaction.response.send_message(embed = confirm, view = view)
                
                await view.wait()
                
                if view.value == True:
                    await member.timeout(duration = datetime.timedelta(seconds = sec, minutes = min, hours = h, days = d), reason = reason)
                    sucess = disnake.Embed(title = Code.Sucess, color = 0x2ECC71)
                    sucess.add_field(name='Нарушитель', value = f'└ {member.mention}')
                    sucess.add_field(name='Модератор', value = '└ {interaction.author.mention}')
                    sucess.add_field(name='Причина', value = '└ `{reason}`')
                    sucess.add_field(name='Спепень выговора', value = f'└{Icons.Timeout} `Таймаут`')
                    await interaction.edit_original_responce(embed = sucess)
                elif view.value == False:
                    canceled = disnake.Embed(title = f'{Icons.Error} Отменено', color = 0xE74C3C)
                    await interaction.edit_original_responce(embed = canceled)
                else:
                    await interaction.edit_original_response(embed = disnake.Embed(description = f"{Icons.Error} Время на ответ вышло!", color = 0xFF0000))

поможете, дам галочку

Ответы

▲ 0Принят

У Вас опечатка: edit_original_responce(embed = canceled)

Правильно: edit_original_response(embed = canceled)

            elif view.value == False:
                canceled = disnake.Embed(title = f'{Icons.Error} Отменено', color = 0xE74C3C)
                await interaction.edit_original_response(embed = canceled)
            else:
                await interaction.edit_original_response(embed = disnake.Embed(description = f"{Icons.Error} Время на ответ вышло!", color = 0xFF0000))