【问题标题】:Remove timestamp from a discord embed从不和谐嵌入中删除时间戳
【发布时间】:2021-02-21 19:43:44
【问题描述】:

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

@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)

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

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

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

    embed.timestamp = discord.Embed.Empty
    

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

    参考资料:

    1. Empty
    2. Embeds

    【讨论】:

      猜你喜欢
      • 2021-01-05
      • 2012-04-13
      • 2021-02-12
      • 1970-01-01
      • 2018-05-04
      • 2018-06-27
      • 1970-01-01
      • 2020-12-27
      相关资源
      最近更新 更多