从不和谐嵌入中删除时间戳

时间:2021-02-21 10:55:25

标签: python discord discord.py

我正在尝试修改现有消息的嵌入,如何从消息中删除或删除时间戳

@commands.command()
async def remove_timestamp(self, ctx, msg: discord.MessageConverter):
   embed = msg.embeds[0]
   embed.timestamp = None #error raised here
   await msg.edit(embed=embed)

当我尝试更新嵌入的颜色或更改时间戳时,类似的代码有效,但删除时间戳会引发错误

1 个答案:

答案 0 :(得分:0)

将嵌入的属性设置为 None 或将其删除可以使用 discord.Embed.Empty

embed.timestamp = discord.Embed.Empty

如果不手动指定,这是 discord.py 使用的默认值。

参考文献:

  1. Empty
  2. Embeds