CODE
import discord
from discord.ext import commands
import sqlite3
from config import settings
bot = commands.Bot(command_prefix = settings['prefix'], intents = discord.Intents.all())
bot.remove_command('help')
connection = sqlite3.connect('server.db')
cursor = connection.cursor()
@bot.event
async def on_ready():
cursor.execute("""CREATE TABLE IF NOT EXISTS users(
name TEXT,
id INT,
cash BIGINT,
rep INT,
lvl INT
)""")
for guild in bot.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None :
cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0,0,1)")
else:
pass
connection.commit()
print('We have logged in as {0.user}'.format(bot))
@bot.event
async def on_member_join(member):
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None :
cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0,0,1)")
connection.commit()
else:
pass
@bot.command(aliases = ['balance', 'cash'])
async def __balance(ctx, member: discord.Member = None):
if member is None:
await ctx.send(embed = discord.Embed(
description=f"""Баланс **{ctx.author}** короче **{cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]}**"""
))
else:
await ctx.send(embed = discord.Embed(
description=f"""Баланс **{member}** короче **{cursor.execute("SELECT cash FROM users WHERE id = {}".format(member.id)).fetchone()[0]}**"""
))
class Menu(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label="Balance", style=discord.ButtonStyle.green)
async def menu1(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.responce.send_message("""**Твой баланс короче ['balance']**""")
@bot.command
async def menu(ctx):
view = Menu()
await ctx.reply(view=view)
bot.run(settings['token'])
i wanna make menu with buttons "balance" "games" "profile" menu like this https://cdn.discordapp.com/attachments/953166970763767868/1083399998139531334/image.png but idk how make buttons to bot write ur balance, or profile with avatar or maybe need go to js?
I tried to write something to guides on various topics with my underdeveloped brains