自分でプレゼントコマンドを作成していますが、プレゼントの終了時刻を埋め込みタイムスタンプとして表示する方法がわかりません。誰か助けてもらえますか?私は埋め込みドキュメントを読みましたが、それは本当に役に立ちませんでした、多分私は愚かです、しかし私はそれを理解することができません。
@bot.command()
async def giveaway(ctx, timer=None):
if not timer:
await ctx.send(f"only use #s for seconds. #m for minutes. #h for hours. #d for days. ")
return
if '.' not in timer:
time_in_sec = 0
if (timer[-1] == 'h') and (timer.count('h') == 1):
time_in_sec = int(timer[:-1]) * 3600
type__ = 'hour'
elif (timer[-1] == 'm') and (timer.count('m') == 1):
time_in_sec = int(timer[:-1]) * 60
type__ = 'minute'
elif (timer[-1] == 's') and (timer.count('s') == 1):
time_in_sec = int(timer[:-1])
type__ = 'second'
elif (timer[-1] == 'd') and (timer.count('d') == 1):
time_in_sec = int(timer[:-1]) * 86400
type__ = 'day'
elif timer.isdigit():
time_in_sec = int(timer)
else:
await ctx.send(f"only use #s for seconds. #m for minutes. #h for hours. #d for days. ")
return
await ctx.message.delete()
timestamp = time.time()
embed = discord.Embed(
title=f"TIMESTAMP TEST",
timestamp=(datetime.datetime.utcfromtimestamp(timestamp)),
color=0x40a0c6,
description=f"**starting giveaway of {timer} {type__}(s)**'")
embed.set_footer(text='__footer__')
await ctx.send(embed=embed)
await asyncio.sleep(time_in_sec)
embed = discord.Embed(
title=f"TIMESTAMP TEST",
timestamp=(datetime.datetime.utcfromtimestamp(timestamp)),
color=0x40a0c6,
description=f"**giveaway of {timer} {type__}(s) is over!**")
embed.set_footer(text='__footer__')
await ctx.send(embed=embed)
else:
await ctx.send('**numbers only work**')
私はそれを考え出した。@FluxedScriptの助けをありがとう!
timestamp = time.time() + time_in_sec
embed = discord.Embed(
title=f"TIMESTAMP TEST",
timestamp=(datetime.datetime.utcfromtimestamp(timestamp)),
color=0x40a0c6,
description=f"**starting giveaway of {timer} {type__}(s)**'")
embed.set_footer(text='Giveaway Ends')
await ctx.send(embed=embed)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加