I am making a discord bot and I need to apply a button and a drop-down list to one message as shown below:
https://i.stack.imgur.com/iHmED.jpg
I'm trying to do this:
def __init__(self):
# The details of the modal, and its components
components = [
disnake.ui.TextInput(
label="Изменение статуса",
placeholder="Введите ваш новый статус",
custom_id="customStatus",
style=TextInputStyle.short,
max_length=12,
)
]
super().__init__(title="Новый статус", components=components)
async def callback(self, inter: disnake.ModalInteraction):
customStatusName = str(inter.text_values['customStatus'])
# print(status)
cursor.execute('UPDATE users SET customStatus = "{}" WHERE id = {}'.format(f"{customStatusName}", inter.author.id))
connection.commit()
await inter.send("Вы успешно поменяли статус!", ephemeral=True)
class EditStatus(disnake.ui.View):
def __init__(self):
super().__init__()
self.value: Optional[bool] = None
@disnake.ui.button(label="Изменить статус", style=disnake.ButtonStyle.grey)
async def cancel(self, button: disnake.ui.Button, inter: disnake.MessageInteraction):
await inter.response.send_modal(modal=MyModal())
self.value = False
class Dropdown(disnake.ui.StringSelect):
def __init__(self):
options = [
disnake.SelectOption(label="Сюрикен", description='значок на баннере'),
disnake.SelectOption(label="Мечи", description='значок на баннере'),
disnake.SelectOption(label="Корона", description='значок на баннере'),
disnake.SelectOption(label="Цветок", description='значок на баннере'),
disnake.SelectOption(label="Звезда", description='значок на баннере'),
]
super().__init__(
placeholder="Выбрать значок...",
min_values=1,
max_values=1,
options=options
)
async def callback(self, inter: disnake.MessageInteraction):
if self.values[0] == 'Сюрикен':
cursor.execute('UPDATE users SET customBadge = "{}" WHERE id = {}'.format('knife', inter.author.id))
connection.commit()
if self.values[0] == 'Мечи':
cursor.execute('UPDATE users SET customBadge = "{}" WHERE id = {}'.format('fight', inter.author.id))
connection.commit()
if self.values[0] == 'Корона':
cursor.execute('UPDATE users SET customBadge = "{}" WHERE id = {}'.format('crown', inter.author.id))
connection.commit()
if self.values[0] == 'Цветок':
cursor.execute('UPDATE users SET customBadge = "{}" WHERE id = {}'.format('flower', inter.author.id))
connection.commit()
if self.values[0] == 'Звезда':
cursor.execute('UPDATE users SET customBadge = "{}" WHERE id = {}'.format('star', inter.author.id))
connection.commit()
await inter.response.send_message(f'Вы успешно поменяли значок на **{self.values[0]}**', ephemeral=True)
class DropdownView(disnake.ui.View):
def __init__(self):
super().__init__()
self.add_item(Dropdown())
view = DropdownView(), EditStatus()
await inter.send(embed=profileEmbed, view=view)```
in the last lines I do it and it doesn't work out for me
Returns an error:
```Command raised an exception: AttributeError: 'tuple' object has no attribute 'to_components'```