【发布时间】:2021-01-21 17:13:08
【问题描述】:
@client.command()
@commands.has_role("Bot Owner")
async def gstart(ctx, mins : int, *, prize: str):
embed = discord.Embed(title="Giveaway!", description=f"{prize}", color=ctx.author.color)
end = datetime.datetime.utcnow() + datetime.timedelta(seconds=mins*60)
embed.add_field(name='Ends At:', value=f"{end} UTC")
embed.set_footer(text=f'Ends {mins} mintues from now!')
my_msg = await ctx.send(embed=embed)
await my_msg.add_reaction("????")
await asyncio.sleep(mins*60)
new_msg = await ctx.channel.fetch_message(my_msg.id)
users = new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
await ctx.send(f"test! {winner.mention} test {prize}!")
问题是当它过期时,我收到以下错误消息:
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
可能是什么问题?
【问题讨论】:
-
这通常是由于
asyncio.sleep()函数的误用造成的。尝试删除await和asyncio.sleep(mins*60)之间的多余空格,因为这可能会导致问题。 -
"这通常是由于误用了 asyncio.sleep() 函数造成的。尝试删除 await 和 asyncio.sleep(mins*60) 之间的额外空间,因为这可能会导致问题。- Shunya 45 分钟前”我试着不工作 :(
标签: python-3.x discord.py