首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在discord.py中获取消息?

如何在discord.py中获取消息?
EN

Stack Overflow用户
提问于 2021-02-25 19:23:30
回答 1查看 579关注 0票数 0

我有一个使用用户提供的参数发送嵌入的命令。我想做一个命令来编辑嵌入,但我不知道如何获取消息,所以我可以编辑它。我当前的代码是:

代码语言:javascript
复制
  @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_messagediscord.TextChannel.fetch_message,但都不起作用。我正在使用discord.py-rewrite分支中的命令框架,该命令在一个目录中,使用该命令的语法为fa!editembed message link | Title | #Colour | Description | Footer。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2021-02-25 20:49:24

await channel.fetch_message仅适用于id,例如await channel.fetch_message(12345)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66367540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档