【问题标题】:Discord.py Disable Button / Freeze Button in embedDiscord.py 在嵌入中禁用按钮/冻结按钮
【发布时间】:2021-12-27 02:10:52
【问题描述】:


我正在尝试制作这个机器人的复制品,当我按下下面的任何按钮时,它会显示一个下拉菜单,你只能使用下拉菜单,其余所有按钮都被冻结或禁用,但我不知道必须这样做,我已经在谷歌上搜索过,但没有任何帮助

这是我一直在尝试的代码

      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)

【问题讨论】:

    标签: python button discord.py dropdown embed


    【解决方案1】:

    你可以使用:

    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 discord_components.Button() 有一个参数:disabled : bool = False

    【讨论】:

      猜你喜欢
      • 2021-11-29
      • 2022-11-16
      • 2021-08-16
      • 1970-01-01
      • 2021-06-24
      • 2022-10-21
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多