有没有办法让机器人编辑自己的消息?我试图寻找一个答案,但找不到答案。
答案 0 :(得分:2)
这将通过代码完成。您只需要以某种方式在您的bot程序中执行它即可。例如,为其执行一个命令,然后可以删除它。
channel = bot.get_channel(id_of_the_channel)
message = await channel.fetch_message(id_of_the_message)
# make sure that you change "id_of_the_channel" for the id of the channel (as an integer)
# and make sure to change "id_of_the_message" for the id of the message (as an integer)
# you can get those by enabling Developer Mode in the Appearance settings in discord
# and right-clicking on the channel to get its id, and right-clicking on the message to get
# its id as well.
await message.edit(content="the new content of the message")
基本上就是这样。通过您的机器人执行这三行代码,它将编辑消息。