我正在尝试为我的机器人程序创建一个免费命令,但每次尝试运行该命令时都会收到错误
第一个月
我的giveaway命令代码
@client.command(description="Starts a giveaway.")
@has_permissions(manage_messages=True)
async def gstart(ctx, time: int, winners: int, *, prize: str):
global users, new_msg
try:
em = discord.Embed(
title=f"<a:fun:1052215771738165269> {prize} <a:fun:1052215771738165269>",
color=discord.Colour.random()
)
timestamp = time.time() + time
em.set_footer(text=f"Started by {ctx.author}")
em.add_field(name=f"** **", value=f"**Ends at**: <t:{int(timestamp)}:f> or <t:{int(timestamp)}:R> \n **Prize**: {prize} \n **Hosted by**: {ctx.author.mention}", inline=False)
my_msg = await ctx.send(embed=em)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await ctx.channel.fetch_message(my_msg.id)
for i in range(winners):
users = [user async for user in new_msg.reactions[0].users()]
users.pop(users.index(client.user))
winner = random.choice(users)
await ctx.send(f'Congratulations {winner.mention} won **{prize}**! Hosted by {ctx.author.mention}')
except Exception as er:
await ctx.send(er)
1条答案
按热度按时间lx0bsm1f1#
你必须重命名你的
time : int
参数,这样它就不会干扰到time
模块。考虑到上下文,我建议使用timeUntil
这样的参数。完整代码: