@UuuuuuuuuuuuuuuuNiX

Ошибка [ERROR ] discord.app_commands.tree: Ignoring exception in command 'reg', поможете?

@app_commands.command(name="reg", description="Регистрация")
    async def reg(self, interaction: discord.Interaction):
        class Form(ui.Modal, title="Регистрация"):
            _name = ui.TextInput(label="Название страны:", min_length=2, max_length=40)
            _ideology = ui.TextInput(label="Идеология:", min_length=2, max_length=25)
            _religion = ui.TextInput(label="Религия:", min_length=2, max_length=25)
            _government_form = ui.TextInput(label="Форма правления:", min_length=2, max_length=25)
    
            async def callback(self, interaction: discord.Interaction):
                # Получение значений из формы
                name = self.values['_name']
                ideology = self.values['_ideology']
                religion = self.values['_religion']
                government_form = self.values['_government_form']
    
                # Вставка данных в таблицу
                f"""INSERT INTO regestration (name, ideology, religion, government_form)
                VALUES ('{str(self._name)}', '{str(self._ideology)}', {self._religion}, {self._government_form})"""
                
                data = (name, ideology, religion, government_form)
                self.cur.execute(insert_query, data)
                self.db.commit()
    
                
                channel_id = 1108327539698585674  
                channel = self.bot.get_channel(channel_id)
    
                if channel is not None:
                    embed = discord.Embed(
                        title="Регистрация",
                        color=discord.Color.blue(),
                        description=f'Название страны: {name}\nИдеология: {ideology}\nРелигия: {religion}\nФорма правления: {government_form}'
                    )
                    await channel.send(embed=embed)

        await interaction.response.send_message(content=None, embed=Form().embed)


Вот код моего окна, хочу создать команду при вызове которой будет появляться окно, где юзеру надо будет указать некоторые данные, и далее данные пойдут в некий канал, но при вводе команды /reg появляется ошибка - [ERROR ] discord.app_commands.tree: Ignoring exception in command 'reg', Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 841, in _do_call
return await self._callback(self.binding, interaction, **params) # type: ignore
File "D:\wpg bot\cogs\command.py", line 62, in reg
await interaction.response.send_message(content=None, embed=Form().embed)
AttributeError: 'Form' object has no attribute 'embed'

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

Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 867, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 860, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'reg' raised an exception: AttributeError: 'Form' object has no attribute 'embed'.

В плане таблицы, в коде она не создана(при этом при запуске кода таблица создалась в дб)
  • Вопрос задан
  • 70 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы