嘿伙计们,我需要帮助制作一个以天/小时/分钟/秒为单位显示时间的赠品命令 现在我只能在赠品消息中以秒为单位确定时间 我找到了一些方法来在命令中以天/小时/分钟/秒为单位而不是机器人发送的消息。
我希望这是有道理的,如果不是我很抱歉
这是我的代码:
@bot.command(aliases=["gcreate"])
async def gstart(ctx, gtime,*, prize):
if ctx.message.author.guild_permissions.manage_messages:
time=convert(gtime)
gembed=discord.Embed(title=f"<a:giveaway:828219055017951292> {prize}", description=f"⏳Time Left : {time} seconds\n?Hosted by : {ctx.author.mention}\nReact with <a:Tada:812191920238886922> to participate", color=0xFF5733)
msg=await ctx.send(f"<a:Gift:828220390551453777> **GIVEAWAY** <a:Gift:828220390551453777>", embed=gembed)
await msg.add_reaction("<a:Tada:812191920238886922>")
while time:
await asyncio.sleep(1)
time-=1
gembed.description=f"⏳Time Left : {time} seconds\n?Hosted by : {ctx.author.mention}\nReact with <a:Tada:812191920238886922> to participate"
await msg.edit(embed=gembed)
new_msg=await ctx.channel.fetch_message(msg.id)
users=await new_msg.reactions[0].users().flatten()
users.pop(users.index(bot.user))
winner = random.choice(users)
gembed.description=f"?Winner : {winner.mention}\n?Hosted by : {ctx.author.mention}"
await msg.edit(content=f"<a:Gift:828220390551453777> **GIVEAWAY ENDED** <a:Gift:828220390551453777>", embed=gembed)
await ctx.send(f"Congratulations! {winner.mention} you won the giveaway of `{prize}`\nDm {ctx.author.mention} for your Rewards!")
else:
await ctx.send(f"Sorry {ctx.author.mention} but you do not have enough perms to use this command\n**__PERMS NEEDED__** <a:arrow_r:825382670514389072> Manage Messages")
@gstart.error
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(f"{ctx.author.mention} Try again in this format:\n""`[!gstart | !gcreate] {time[s|m|h|d]} {prize}`")
提前致谢