我有一个使用用户提供的参数发送嵌入的命令。我想做一个命令来编辑嵌入,但我不知道如何获取消息,所以我可以编辑它。我当前的代码是:
@commands.command(description='Edits an embed message using the provided message link.')
async def editembed(self, ctx, *, args=None):
if args == None:
#code here
else:
editConfig=args.split(" | ")
if len(editConfig) > 5:
await ctx.send("Too many arguments!")
else:
editConfig[0] = editConfig[0].lstrip("https://discord.com/channels/")
linkConfig = editConfig[0].split("/")
channel = self.bot.get_channel(linkConfig[1])
messageID = await channel.fetch_message(linkConfig[2])
embed=discord.Embed(title=editConfig[1], description=editConfig[3], colour=int(editConfig[2][1:],16))
embed.set_footer(test=embedConfig[4])
embed.timestamp = datetime.now()
await message.edit(embed=embed)代码在fetch_message上卡住了。我尝试过使用channel.fetch_message和discord.TextChannel.fetch_message,但都不起作用。我正在使用discord.py-rewrite分支中的命令框架,该命令在一个目录中,使用该命令的语法为fa!editembed message link | Title | #Colour | Description | Footer。谢谢!
发布于 2021-02-25 20:49:24
await channel.fetch_message仅适用于id,例如await channel.fetch_message(12345)
https://stackoverflow.com/questions/66367540
复制相似问题