Answer the question
In order to leave comments, you need to log in
How to add nicknames of people from discord (discord.py) to sqlite3 database?
I want to create a command in which the nickname of the user who entered the command will be entered into the database. Also, along with his nickname, the n-th amount of experience and the n-th amount of coins (ie 3 columns) will be entered, please help! How to do it? My code:
from os import curdir
from discord.ext import commands
import discord
from random import *
import sqlite3
TOKEN = ""
# Задать переменные
bot = commands.Bot(command_prefix=('!'))
bot.remove_command( 'help' )
# Создание переменной connect и объекта cursor
connect = sqlite3.connect("eco.db")
cursor = connect.cursor()
# Создание базы данных
cursor.execute("CREATE TABLE IF NOT EXISTS userinfos(id TEXT INTEGER)")
connect.commit()
@bot.command()
async def старт(ctx):
author = ctx.message.author
cursor.execute(f"""INSERT INTO userinfos(<{author.mention}>)""")
connect.commit()#применение изменений в БД
bot.run(TOKEN)
Answer the question
In order to leave comments, you need to log in
I have a guess how to do it:
@bot.command()
async def start(ctx):
author = ctx.message.author
cursor.execute("INSERT INTO userinfos ({author.mention})")
But doesn't work
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question