Python
- 7 ответов
- 0 вопросов
7
Вклад в тег
async def findRoleByName(guild,name:str):
for role in guild.roles:
if name.lower() in role.name.lower():
return role #вернет сам объект роли
else:
return None
class MyClass:
@client.command()
async def _init_(sefl,ctx):
self.moder = None
embed = discord.Embed(
title='Это мой заголовок',
description='Это мой основной текст',
color=0x83c837)
self.moder = await ctx.send(embed=embed)
@client.command()
async def test(sefl,ctx):
await ctx.send(
self.moder
)
import discord
from discord.ext import commands
import sqlite3
client = commands.Bot(command_prefix = "!")
client.remove_command('help')
connection = sqlite3.connect('users.db')
cursor = connection.cursor()
@client.event
async def on_ready():
cursor.execute("""CREATE TABLE users (name TEXT,id INT,cash BIGINT,rep INT,lvl INT)""")
for guild in client.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('bot connected')
@client.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
@client.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])}**"""
))
client.run()