'why does the bot doesnt send the db pycord
My bot doesn't write changes on the DB when I type the command with the id What I want to do: write the commmand + the ID of the person -> the bot add the person ID and points in the DB -> send a message to say it worked
my code :
@bot.command()
@commands.has_permissions(administrator=True)
async def staff(ctx, user: Optional[discord.Member]):
if user == None:
await ctx.respond("Please add the staff id")
else:
db = sqlite3.connect("main.db")
c = db.cursor()
c.execute("SELECT points FROM staff WHERE id=?")
results = c.fetchall()
print(results)
if len(results) == 0:
c.execute(f"INSERT INTO staff(id, points) VALUES(?,?)", {user.id, 0})
await ctx.respond("done")
else:
await ctx.respond("this already exists")
db.commit()
I use sqlite3 DB
and in the console there is no error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|