首页 > 解决方案 > 试图制作一个服务器机器人,但日期时间有问题,我不明白它是什么

问题描述

错误:第 16 行,赠品结束 = datetime.datetime.utcnow() + datetime.timedelta(seconds=mins*60) TypeError: unsupported operand type(s) for *: 'type' and 'int'

我的代码是:

    embed = discord.Embed(title= "Giveaway!",description = f"{prize}")
    end= datetime.datetime.utcnow() + datetime.timedelta(seconds= mins*60)
    embed.add_field(name="Ends In:", value= f"{end} UTC")
    embed.set_footer(text=f"Ends {mins} Minutes From Now")
    msg = await ctx.send(embed=embed)
    await msg.add_reaction('')
    await asyncio.sleep(mins*60)
    new_msg =await ctx.channel.fetch_message(msg.id)
    users = await new_msg.reaction[0].users().flatten()
    users.pop(users.index(client.user))
    win = random.choice(users)
    await ctx.send(f"Congratulations {win.mention} You Just Won {prize}")

标签: pythonpython-3.xdiscordbots

解决方案


你的代码没有显示mins赋值,我认为问题出在mins变量中,确保它是一个整数并尝试像这样放置括号seconds= (mins*60)


推荐阅读