Answer the question
In order to leave comments, you need to log in
Constantly else although it should beat True how to fix it?
@client.command()
async def addblack(ctx,userid):
owner = 634060873731670018
author = ctx.message.author
if author.id == owner:
sql.execute(f'SELECT userid FROM badusers')
if sql.fetchone() is None:
sql.execute(f'INSERT INTO badusers VALUES (?) ', ({userid}))
db.commit()
await ctx.send('готово!')
else:
await ctx.send('он уже есть в бд!')
else:
await ctx.send('вы не имеете достаточного права чтоб добавлять его как крашера!')
Answer the question
In order to leave comments, you need to log in
Because you are using SQL incorrectly. The query selects all records from badusers, not just a specific user_id. As far as I can see, it is supposed to check if there is a user and enter it.
sql.execute(f'SELECT userid FROM badusers WHERE user_id = ?', (user_id, ))
sql.execute(f'INSERT INTO badusers VALUES (?) ', (userid, ))
See what sql.fetchone()
returns. There is clearly something there, but not None.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question