servers_db = sqlite3.connect('servers.db')
servers_sql = servers_db.cursor()
servers_sql.execute("""CREATE TABLE IF NOT EXISTS servers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
guild INT,
admin_channel INT
)""")
@bot.command()
async def admin_channel(ctx):
channel = ctx.message.channel.id
guild = int(ctx.message.guild.id)
servers_sql.execute(f"SELECT admin_channel FROM servers WHERE guild = '{guild}' ")
print(servers_sql.fetchone())
if servers_sql.fetchone() is None:
servers_sql.execute(f"INSERT WHERE guild = '{guild}' INTO servers(admin_channel) VALUES ('{channel}') ")
servers_sql.execute('SELECT * FROM servers')
rows = servers_sql.fetchall()
for row in rows:
print(row)
else:
#await channel.send('Бот уже был на этом сервере, ID добавлен')
print("again")
servers_db.commit()