Совмещение buttons и SelectMenu
Столкнулся с проблемой совмещения кнопок и селект меню. В селект меню человек получает какие-то роли. А по нажатию кнопки, роли, что выбрал человек, снимались. Так вот. У меня не получается добавить работающею кнопку, которая снимала бы эти роли.
Сам код:
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Роль 1", description="Получить роль 1", value=str(1066196080791932978)),
discord.SelectOption(label="Роль 2", description="Получить роль 2", value=str(1066196591440044122)),
discord.SelectOption(label="Роль 3", description="Получить роль 3", value=str(1066196709551636481)),
]
super().__init__(placeholder="Получить Роли", min_values=1, max_values=1, options=options)
async def callback(self, inter: discord.Interaction):
await inter.user.add_roles(get(inter.guild.roles, id=int(self.values[0])))
await inter.response.send_message(f"Вы получили роль <@&{self.values[0]}>", ephemeral=True)
class buttons(discord.ui.Button):
@discord.ui.button(label="Снять роли", style=discord.ButtonStyle.red)
async def callback(self, inter: discord.Interaction):
await inter.user.remove_roles(int({self.values[0]}))
await inter.response.send_message("Роли сняты", ephemeral=True)
class DropdownViewFR(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.add_item(Select())
self.add_item(buttons())
@bot.command()
async def roles(ctx):
await ctx.channel.purge(limit = 1)
await ctx.send(view=DropdownViewFR())
Получаю ошибку:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.1.components.0.label: This field is required
Благодарен всем за прочтение и возможную помощь!