discord.py 事件结束后如何发送

How to send when an event has ended in discord.py

我正在尝试获得这样的输出,其中显示消息的发送时间

消息发送成功收到

    emb = discord.Embed(title=f"**{title}**", description=f"<:854745395314163784:910908229897297940> Ends in {lenght}")
    emb.set_thumbnail(url='https://images-ext-2.discordapp.net/external/D14-NqrYBiv91a8nM8tVD4b0SuN-CAUlmooEq0dtWsM/https/kaj.gg/r/kq902alos9a.png?width=80&height=80')
    emb.set_footer(text = f"{winners} Winner")
    msg_2 = await ctx.send(embed=emb)
    await msg_2.add_reaction(emoji)
    id = msg_2.id
    created = msg_2.created_at
    print(created)

但我不知道如何 return 像“几秒钟前结束”或“几小时前结束”这样的消息

您发送的示例使用了 Discord 的内置时间戳格式,概述了 here。您可以通过在 msg_2.created_at 上使用 datetime 的 timestamp() 函数来获取 Unix 时间戳,例如您的示例:
f"<t:{int(msg_2.created_at.replace(tzinfo=datetime.timezone.utc).timestamp())}:R>"
然后您可以正常将该字符串包含在消息中。