ram kador
ram kador

Reputation: 49

trying to make a server bot but there is a problem with datetime and i dont understand what it is

error:line 16, in giveaway end= datetime.datetime.utcnow() + datetime.timedelta(seconds=mins*60) TypeError: unsupported operand type(s) for *: 'type' and 'int'

my code is:

    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}")

Upvotes: 0

Views: 25

Answers (1)

Ahmed Alnour
Ahmed Alnour

Reputation: 51

your code doesn't show mins assignment, I think the problem is in the mins variable, make sure it is an integer and try to put parentheses like this seconds= (mins*60)

Upvotes: 2

Related Questions