Reputation: 23
i am making pointing system in discord.py. I am using sqlite3 database and i have following problem:
async def solved(ctx, member : discord.Member):
c.execute(f'SELECT name FROM math WHERE name = "{member.name}"')
checkname = c.fetchone()
if checkname == member.name:
c.execute(f"INSERT INTO math VALUES('{member.name}', 40, '{ctx.guild.id}')")
await ctx.send("User is in database")
c.execute(f"SELECT qula FROM math WHERE name = '{member.name}'")
qula = c.fetchone()
print(qula)
saboloo = int(qula[1]) + 40
c.execute("UPDATE math SET qula = ? WHERE name = ?", (saboloo, member.name))
await ctx.send("You earned 40 coins.")
print(checkname)
elif checkname != member.name:
print(checkname)
c.execute(f"INSERT INTO math VALUES('{member.name}', 40, '{ctx.guild.id}')")
await ctx.send("User is not in database")```
Every time I type this command, the bot says that the user is not in the database.
Upvotes: 0
Views: 33
Reputation: 194
You should use member.id not member.name - they can change their nickname anytime but id stays the same. That may cause you some problems
Try using this:
c.execute(f"SELECT name FROM math WHERE name='{member.name}'")
Upvotes: 1