import disnake
from disnake.ext import commands
import datetime
import sqlite3
connection = sqlite3.connect('server.db')
cursor = connection.cursor()
class INFO(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
cursor.execute("""CREATE TABLE IF NOT EXISTS banner(
link_banner TEXT,
author INT
)""")
connection.commit()
print('INFO cog on_ready')
@commands.command()
async def set_banner(self, ctx, link_banner: str = None):
if link_banner is None:
await ctx.reply('Укажите ссылку на картинку кторую вы хотите видеть на баннере')
else:
cursor.execute(f"INSERT INTO banner VAlUES (?, ?)", (ctx.author.id, link_banner))
connection.commit()
await ctx.reply('Готово!')
@commands.command(aliases = ['инфо', 'п', 'профиль', 'и', 'profile', 'p', 'i'])
async def info(self, ctx, member: disnake.Member = None):
banner = cursor.execute("SELECT link_banner FROM banner WHERE author = {}".format(ctx.author.id))
if member is None:
member = ctx.author
roles = []
for role in member.roles:
if role.name != "@everyone":
roles.append(role.mention)
b = ",".join(roles)
create_acc = disnake.utils.format_dt(member.created_at, style = 'D')
joined_acc = disnake.utils.format_dt(member.joined_at, style = 'D')
embed = disnake.Embed(
colour = 0x2F3136
)
embed.set_author(
name = member,
icon_url = member.avatar
)
embed.add_field(
name = 'ID:',
value = member.id
)
embed.add_field(
name = 'Аккаунт создан:',
value = create_acc
)
embed.add_field(
name = 'Зашел на сервер:',
value = joined_acc
)
embed.add_field(
name = f'Роли ({len(roles)}):',
value = ''.join([b])
)
embed.set_image(
url = banner
)
await ctx.reply(embed = embed)
@commands.slash_command(name = 'info', description = 'Команда которая показывает информацию о пользователе')
async def info_slash(self, ctx: disnake.ApplicationCommandInteraction, member: disnake.Member = None):
if member is None:
member = ctx.author
roles = []
for role in member.roles:
if role.name != "@everyone":
roles.append(role.mention)
b = ",".join(roles)
create_acc = disnake.utils.format_dt(member.created_at, style = 'D')
joined_acc = disnake.utils.format_dt(member.joined_at, style = 'D')
embed = disnake.Embed(
colour = 0x2F3136
)
embed.set_author(
name = member,
icon_url = member.avatar
)
embed.add_field(
name = 'ID:',
value = member.id
)
embed.add_field(
name = 'Аккаунт создан:',
value = create_acc
)
embed.add_field(
name = 'Зашел на сервер:',
value = joined_acc
)
embed.add_field(
name = f'Роли ({len(roles)}):',
value = ''.join([b])
)
await ctx.send(embed = embed)
@commands.command()
async def send(self, ctx):
await ctx.reply(cursor.execute("SELECT link_banner FROM banner WHERE author = {}".format(ctx.author.id)))
def setup(bot):
bot.add_cog(INFO(bot))