在 (()) 中放入什么以使机器人记住它将发送的消息的 ID?有没有办法将下一条(例如用户的)消息(尚未发送)的 id 作为变量?
蓝山帝景
浏览 149回答 2
2回答
MMTTMM
ctx.send()返回discord.Message它发送的消息的实例,因此您可以将其存储在变量中。message = await ctx.send(f"{ctx.message.author.mention}, Hi!")# do what you want with the message, in your case getting it's idbot_message_id = message.id至于你的第二个问题,如果你想获得用户对该消息的响应(因此特定用户将发送的下一条消息),你可以使用内置函数wait_for。def check(message): return message.author.id == the_id_of_that_usermessage = await bot.wait_for("message", check=check)这样,机器人实际上就会发出wait for一条消息,使您的check函数返回True,或者在本例中是由该用户发送的消息。