Discord.py 在嵌入中禁用按钮/冻结按钮
Discord.py Disable Button / Freeze Button in embed
我正在尝试复制这个机器人,当我按下下面的任何按钮时,它会显示一个下拉菜单,你只能使用下拉菜单,其余所有按钮都被冻结或禁用,但我不知道必须这样做,我已经在 google 上搜索过这个但没有任何帮助
这是我一直在尝试的代码
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
discord_components.Button() 有一个参数:disabled : bool = False
.
我正在尝试复制这个机器人,当我按下下面的任何按钮时,它会显示一个下拉菜单,你只能使用下拉菜单,其余所有按钮都被冻结或禁用,但我不知道必须这样做,我已经在 google 上搜索过这个但没有任何帮助
这是我一直在尝试的代码
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
discord_components.Button() 有一个参数:disabled : bool = False
.