Discord.py 嵌入中禁用按钮/冻结按钮

2024-05-16

enter image description here
I'm trying to make a replica of this bot, in which when I press any of the buttons below, it shows a dropdown menu, and you can only use the dropdown menu, rest of all the buttons are frozen or disabled, but I have not idea have to do that , I have searched on google for this but nothing helped

这是我一直在尝试的代码

      Button(
          style=ButtonStyle.gray ,
          label="Add Req.",
          custom_id="add_req",
          emoji='➕'),
      Button(
          style=ButtonStyle.gray,
          label="Add Mult.",
          custom_id="add_mult",
          emoji='➕'))

  columns_of_buttons = ActionRow(
      Button(
          style = ButtonStyle.gray,
          label= "Remove Item",
          custom_id="remove_item",
          emoji='➖'),
      Button(  
          style = ButtonStyle.gray,
          label= "Start",
          custom_id="start",
          emoji='➡'))

  msg = await ctx.send(embed = embed ,components= [row_of_buttons , columns_of_buttons])
  on_click = msg.create_click_listener(timeout=60)
  @on_click.matching_id("add_req")
  async def add_req(ctx):
      embed.clear_fields()
      emb = discord.Embed(title = 'Add new Requirement' , description = '**Choose a requirement type**')
      await msg.edit(embed = emb , components=[])
        ```

**EDIT**

I successfully did it by doing this

    ActionRow.disable_buttons(row_of_buttons)
    ActionRow.disable_buttons(columns_of_buttons)


您可以使用:

from discord_components import Button
Button(style = ButtonStyle.gray,
          label= "Remove Item",
          custom_id="remove_item",
          emoji='➖',
          disabled = True)

读这个:https://discord-components.readthedocs.io/en/0.5.2.4/pages/button.html?highlight=button%20disable#discord_components.button.Button.disabled https://discord-components.readthedocs.io/en/0.5.2.4/pages/button.html?highlight=button%20disable#discord_components.button.Button.disabledDiscord_components.Button() 有一个参数:disabled : bool = False.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Discord.py 嵌入中禁用按钮/冻结按钮 的相关文章

随机推荐