• 1000 Вот код:
import discord
from discord.ext import commands
import sqlite3
client = commands.Bot(command_prefix='!')
client.remove_command('help')
connection = sqlite3.connect('server.db')
cursor = connection.cursor()
@client.event
async def on_ready():
cursor.execute("""CREATE TABLE IF NOT EXISTS shop (
role_id INT,
id INT,
cost BIGINT
)""")
@client.command(aliases = ['buy', 'buy-role'])
async def __buy(ctx, role: discord.Role = None):
if role is None:
await ctx.send(f"**{ctx.author}**, choose a role, which you want to buy!")
else:
if role in ctx.author.roles:
await ctx.send(f"**{ctx.author}**, you already have this role!")
elif cursor.execute("SELECT cost FROM shop WHERE role_id = {}".format(role.id)).fetchone()[0] > cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]:
await ctx.send(f'**{ctx.author}**, not enough money!')
else:
await ctx.author.add_roles(role)
cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(("SELECT cost FROM shop WHERE role_id = {}".format(role.id)).fetchone()[0], ctx.author.id))
connection.commit()
await ctx.message.add_reaction('✅')
client.run('MY TOKEN')
ПОМОГИТЕ!