Aslan
Aslan

Reputation: 33

Why python if command doesnt work correctly?

@Bot.command()
async def kod(ctx,discordid):
    objects = Code.manager(db)
    code_list = list(objects.all())
    i = 1
    while i <= len(code_list):
        usercode = objects.get(i)
        usercode = usercode.__dict__
        id = usercode.get('discord_id')
        print(discordid)
        print(id)
        if discordid == id:
            await ctx.send("worked")
        i = i + 1

I have problem with if command.you can see the result of the print(id) and print(discordid) code here:

806114153915875378
806114153915875378

You can see that discordid and id are the same. But

if discordid == id:
    await ctx.send("worked")

Code doesnt work correctly and bot doesnt send message.There isnt a error printed at terminal.

Upvotes: 1

Views: 86

Answers (1)

Dhawal
Dhawal

Reputation: 81

Try this program

if str(discordid) == str(id):
    await ctx.send("worked")

Upvotes: 1

Related Questions