基本上,互动只是一个echec

我的代码:
import disnake
from disnake import Intents
from disnake.ext.commands import Context, Bot
bot = Bot(command_prefix='+', test_guilds=[1032280589031706706], help_command=None, intents=Intents.all())
@bot.event
async def on_ready():
print('ready')
@bot.command()
async def test(ctx: Context):
view = DropdownView()
await ctx.send(embed=disnake.Embed(description='>\n '), view=view)
class Dropdown(disnake.ui.Select):
def __init__(self):
self.Embedtitle = None
self.Embeddescription = '>\n'
options = [
disnake.SelectOption(
label="Red", description="Your favourite colour is red", emoji=""
),
disnake.SelectOption(
label="Green", description="Your favourite colour is green", emoji=""
),
disnake.SelectOption(
label="Blue", description="Your favourite colour is blue", emoji=""
),
]
# The placeholder is what will be shown when no option is chosen.
# The min and max values indicate we can only pick one of the three options.
# The options parameter defines the dropdown options, see above.
super().__init__(
placeholder="Choose your favourite colour...",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, inter: disnake.MessageInteraction):
print(f"Your favourite colour is {self.values[0]}")
def check(m:disnake.Message):
return inter.author.id == m.author.id and m.content != ''
msg = await bot.wait_for('message', check=check, timeout=120.0)
self.Embeddescription=msg
await inter.response.edit_message(embed=disnake.Embed(
colour=None,
title=self.Embedtitle,
description=self.Embeddescription,
))
class DropdownView(disnake.ui.View):
def __init__(self):
super().__init__()
# Add the dropdown to our view object.
self.add_item(Dropdown())
bot.run("token")代码来自官方债券回购,因为我最初认为我的代码有问题,但是经过一些测试后,我现在知道由于bot.wait_for()的缘故,插入是echec。
我试着做一个嵌入编辑器机器人,
输入命令+embed,bot返回嵌入,您可以在选择菜单中选择项来编辑描述、页脚等。并将其发送到信道中。
例:
机器人发送一个空的嵌入来预览当我们完成后将发送的嵌入,
我们可以选择编辑什么(描述、标题、作者、字段等)
当我们选择要编辑的内容时,bot只会提示它如下
What will be the description
我们发送一条包含描述的消息
我试图让机器人提示新的描述/标题/作者/等等。对于bot.wait_for(),但它似乎根本不起作用,有任何解决方案吗?
发布于 2022-10-29 16:14:44
我只需打电话就能解决这个问题
await inter.response.defer()就在回调函数之后。
https://stackoverflow.com/questions/74242173
复制相似问题