在Discord.py中添加任何UNIX时间戳
“ https://i.sstatic.net/dbhuf.png”中添加unix timestamp
我想在此
@client.command()
async def giveaway(ctx, days:int, hours:int, minutes:int, seconds:int, prize:str):
time = days + hours + minutes + seconds
embed = discord.Embed(title=prize, description=f"time: <t:{time}:R>")
await ctx.send(embed=embed, delete_after=time)
endembed = discord.Embed(title=f"you have won {prize}", description="The time has ended")
await ctx.send(embed=endembed)
i want to add unix timestamp in the giveaway time like in this image
here is the code:
@client.command()
async def giveaway(ctx, days:int, hours:int, minutes:int, seconds:int, prize:str):
time = days + hours + minutes + seconds
embed = discord.Embed(title=prize, description=f"time: <t:{time}:R>")
await ctx.send(embed=embed, delete_after=time)
endembed = discord.Embed(title=f"you have won {prize}", description="The time has ended")
await ctx.send(embed=endembed)
when I run the code it shows me this image
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在时间模块中使用
mktime
函数来执行此操作。返回的值应该像这样有点像这样:
&lt; t:1655392367:r&gt;
粘贴返回的字符串将提供一个动态显示,如您提供的图像所示。
MKTime
函数返回浮点值。为了使日期时间动态显示,两者之间的值必须仅为数字。返回的字符串末尾的
r
代表相对
。动态显示将相对于当前时间。 其他格式是t
,,> t
,d
,d
,f
和f
。You can do this by using the
mktime
function in the time module.The returned value should like somewhat like this:
<t:1655392367:R>
Pasting the returned string will give a dynamic display as shown in the image you have provided.
The
mktime
function returns a float value. For the datetime to be displayed dynamically, the value in between must be numbers only.The
R
in the end of the returned string stands forrelative
. The dynamic display will be relative to current time. The other formats aret
,T
,d
,D
,f
andF
.