сделай, чтобы после нажатия на кнопку остальные стали неактивными @bot.command() async…
- User
сделай, чтобы после нажатия на кнопку остальные стали неактивными
@bot.command() async def обращение(ctx): buttons = [ Button(style=ButtonStyle.green, label="Помощь", custom_id="помощь", emoji="📨"), Button(style=ButtonStyle.primary, label="Баг-репорт", custom_id="баг-репорт", emoji="📝"), Button(style=ButtonStyle.red, label="Жалоба на лидера", custom_id="жалоба_на_лидера", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на игрока", custom_id="жалоба_на_игрока", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на администратора", custom_id="жалоба_на_администратора", emoji="⚠️") ]
embed = disnake.Embed(title="Выберите тип обращения", color=disnake.Color.blue()) await ctx.send(embed=embed, components=[buttons], ephemeral=True) interaction = await bot.wait_for("button_click", check=lambda i: i.user == ctx.author) response_embed = disnake.Embed(title=f"Выбрано обращение: {interaction.component.label}", color=disnake.Color.blue()) await interaction.response.send_message(embed=response_embed, ephemeral=True) command_ctx = await bot.get_context(interaction.message) command_ctx.author = interaction.user if interaction.component.custom_id == "помощь": command_ctx.command = bot.get_command("помощь") elif interaction.component.custom_id == "баг-репорт": command_ctx.command = bot.get_command("баг") elif interaction.component.custom_id == "жалоба_на_лидера": command_ctx.command = bot.get_command("жалоба_на_лидера") elif interaction.component.custom_id == "жалоба_на_игрока": command_ctx.command = bot.get_command("жалоба_на_игрока") elif interaction.component.custom_id == "жалоба_на_администратора": command_ctx.command = bot.get_command("жалоба_на_администратора") await bot.invoke(command_ctx)сделай, чтобы после нажатия на кнопку остальные стали неактивными
@bot.command() async def обращение(ctx): buttons = [ Button(style=ButtonStyle.green, label="Помощь", custom_id="помощь", emoji="📨"), Button(style=ButtonStyle.primary, label="Баг-репорт", custom_id="баг-репорт", emoji="📝"), Button(style=ButtonStyle.red, label="Жалоба на лидера", custom_id="жалоба_на_лидера", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на игрока", custom_id="жалоба_на_игрока", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на администратора", custom_id="жалоба_на_администратора", emoji="⚠️") ]
embed = disnake.Embed(title="Выберите тип обращения", color=disnake.Color.blue()) await ctx.send(embed=embed, components=[buttons], ephemeral=True) interaction = await bot.wait_for("button_click", check=lambda i: i.user == ctx.author) response_embed = disnake.Embed(title=f"Выбрано обращение: {interaction.component.label}", color=disnake.Color.blue()) await interaction.response.send_message(embed=response_embed, ephemeral=True) command_ctx = await bot.get_context(interaction.message) command_ctx.author = interaction.user if interaction.component.custom_id == "помощь": command_ctx.command = bot.get_command("помощь") elif interaction.component.custom_id == "баг-репорт": command_ctx.command = bot.get_command("баг") elif interaction.component.custom_id == "жалоба_на_лидера": command_ctx.command = bot.get_command("жалоба_на_лидера") elif interaction.component.custom_id == "жалоба_на_игрока": command_ctx.command = bot.get_command("жалоба_на_игрока") elif interaction.component.custom_id == "жалоба_на_администратора": command_ctx.command = bot.get_command("жалоба_на_администратора") await bot.invoke(command_ctx) - Assistant
Для того чтобы после нажатия на кнопку остальные кнопки стали неактивными, вы можете использовать метод "disable()" для каждой кнопки, кроме выбранной. Вот обновленный код:
@bot.command() async def обращение(ctx): buttons = [ Button(style=ButtonStyle.green, label="Помощь", custom_id="помощь", emoji="📨"), Button(style=ButtonStyle.primary, label="Баг-репорт", custom_id="баг-репорт", emoji="📝"), Button(style=ButtonStyle.red, label="Жалоба на лидера", custom_id="жалоба_на_лидера", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на игрока", custom_id="жалоба_на_игрока", emoji="⚠️"), Button(style=ButtonStyle.red, label="Жалоба на администратора", custom_id="жалоба_на_администратора", emoji="⚠️") ] embed = disnake.Embed(title="Выберите тип обращения", color=disnake.Color.blue()) await ctx.send(embed=embed, components=[buttons], ephemeral=True) interaction = await bot.wait_for("button_click", check=lambda i: i.user == ctx.author) response_embed = disnake.Embed(title=f"Выбрано обращение: {interaction.component.label}", color=disnake.Color.blue()) await interaction.response.send_message(embed=response_embed, ephemeral=True) command_ctx = await bot.get_context(interaction.message) command_ctx.author = interaction.user if interaction.component.custom_id == "помощь": command_ctx.command = bot.get_command("помощь") elif interaction.component.custom_id == "баг-репорт": command_ctx.command = bot.get_command("баг") elif interaction.component.custom_id == "жалоба_на_лидера": command_ctx.command = bot.get_command("жалоба_на_лидера") elif interaction.component.custom_id == "жалоба_на_игрока": command_ctx.command = bot.get_command("жалоба_на_игрока") elif interaction.component.custom_id == "жалоба_на_администратора": command_ctx.command = bot.get_command("жалоба_на_администратора") # Отключаем все кнопки, кроме выбранной for button in buttons: if button.custom_id != interaction.component.custom_id: button.disable() await bot.invoke(command_ctx)В этом обновленном коде после нажатия кнопки все остальные кнопки будут отключены путем вызова метода "disable()" для каждой кнопки, кроме выбранной кнопки.