Я манал, а ведь только начал учить, уже ошибки, которые решить не могу. Вот код:
@client.event
async def on_member_join(member): ###add a row in the db for the new member when they join
user = member.id
conn = sqlite3.connect('leveling.db')
cur = conn.cursor()
cur.execute('INSERT INTO table_name_here("userid", "xp", "level")VALUES(user, 0, 0)')
conn.commit()
conn.close()
await member.send("Your welcome message here")
@client.event
async def on_message(message):
user = message.author.id
con = sqlite3.connect('leveling.db')
cur = conn.cursor()
cur.execute('SELECT xp, level FROM table_name_here WHERE userid = ?')
results = cur.fetchone()
row = results[0] ### results will be a list and since you're only fetching one record in this instance, you only need the first index
old_xp = row[0] ##the first item in the index, in this case, xp
old_level = row[1] ## the second item in the index, in this case, level
new_xp = old_xp + 1
if new_xp == 25: #this is where you set the threshold for leveling up to the first level
new_level = 1
else:
new_level = old_level
###add more logic here for successive level-ups
cur.execute('UPDATE table_name_here SET xp = ?, level = ? WHERE userid = ?', (new_xp, new_level, user)
con.commit()
con.close()
Выдает:
con.commit()
^
SyntaxError: invalid syntax