Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil12-dev authored Jul 24, 2023
1 parent 1c1e01a commit fa17a66
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 70 deletions.
8 changes: 4 additions & 4 deletions cogs/AutoRole.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def on_member_join(self, member: disnake.Member):
role = guild.get_role(role_id)
try:
await member.add_roles(role)
emb = disnake.Embed(title=f"Привет {member.display_name}!", color=0x7788ff)
emb = disnake.Embed(title=f"Привет {member.display_name}!", color=0xCD853F)
emb.description = f"Я назначила тебе роль **{role.name}** на сервере {guild.name}."
await member.send(embed=emb)
except disnake.errors.Forbidden:
Expand All @@ -43,13 +43,13 @@ async def set_default_role(self, ctx, role: disnake.Role = None):

embed = disnake.Embed(
title=f"Роль {role.name} установлена как роль по умолчанию.",
color=0x7788ff
color=0xCD853F
)
else:
embed = disnake.Embed(
title="Ошибка при установке роли по умолчанию!",
description="Укажите корректную роль",
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -59,7 +59,7 @@ async def set_default_role_error(self, ctx, error):
embed = disnake.Embed(
title="Ошибка при установке роли по умолчанию!",
description="У вас нет разрешения управлять ролями!",
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand Down
72 changes: 44 additions & 28 deletions cogs/admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sqlite3
import os
import sys
import typing
from datetime import datetime


Expand All @@ -28,17 +27,22 @@
class admins(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot





@commands.slash_command(name="kick", description="Выгнать пользователя с сервера.")
@commands.has_permissions(kick_members=True, administrator=True)
async def kick_user(self, ctx: disnake.ApplicationCommandInteraction, user: disnake.Member, reason: str = None):
await user.kick(reason=reason)
embed=disnake.Embed(color=0x7788ff)
embed.add_field(name="Kick", value=f"{ctx.author.mention} кикнула {user.mention} из {ctx.guild} сервера")
await ctx.send(embed=embed, ephemeral=True)
try:
await user.send(f"Вы были кикнуты с сервера {ctx.guild.name}. Причина: {reason}")
except disnake.errors.HTTPException:
pass
embed = disnake.Embed(color=0xCD853F)
embed.add_field(name="Kick", value=f"{ctx.author.mention} кикнула {user.mention} из {ctx.guild} сервера 😔")
embed.add_field(name="Причина", value=reason if reason else "Не указана")

await ctx.send(embed=embed, ephemeral=True)



@commands.slash_command(name='clear', description='Очистить чат')
Expand All @@ -50,7 +54,7 @@ async def clear(self, ctx: disnake.ApplicationCommandInteraction, amount: int):
await ctx.send('Кискис нельзя удалить больше 1000 сообщений за раз.')
return
deleted = await ctx.channel.purge(limit=amount)
embed=disnake.Embed(color=0x7788ff)
embed=disnake.Embed(color=0xCD853F)
embed.add_field(name="Очистила чат", value=f"Удалила {len(deleted)} сообщений 😊", inline=False)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -64,12 +68,16 @@ async def ban_user(self, ctx: disnake.ApplicationCommandInteraction, user: disna
c.execute("SELECT user_id FROM bans WHERE user_id=?", (user.id,))
banned_user = c.fetchone()
if banned_user:
embed = disnake.Embed(title="Бан", description=f"{user.mention} Этот пользователь уже забанен.", color=0x7788ff)
embed = disnake.Embed(title="Бан", description=f"{user.mention} Этот пользователь уже забанен.", color=0xCD853F)
else:
await user.ban(reason=reason)
c.execute("INSERT INTO bans (user_id, username, reason) VALUES (?, ?, ?)", (user.id, user.name, reason))
conn.commit()
embed = disnake.Embed(title="Бан", description=f"{user.mention} Я забанила эту хамку.😤", color=0x7788ff)
embed = disnake.Embed(title="Бан", description=f"{user.mention} Я забанила эту хамку.😤", color=0xCD853F)
try:
await user.send(embed=embed)
except disnake.errors.HTTPException:
pass
await ctx.send(embed=embed, ephemeral=True)


Expand All @@ -82,11 +90,19 @@ async def unban_user(self, ctx: disnake.ApplicationCommandInteraction, user: dis
banned_user = banned_entry.user
if (banned_user.name, banned_user.discriminator) == (user_name, user_discriminator):
await ctx.guild.unban(banned_user, reason=reason)
conn = sqlite3.connect('bans.db')
c = conn.cursor()
c.execute("DELETE FROM bans WHERE user_id=?", (banned_user.id,))
conn.commit()
embed = disnake.Embed(title="Разбан", description=f"{banned_user.mention} был успешно разбанен.", color=0x7788ff)
embed = disnake.Embed(title="Разбан", description=f"{banned_user.mention} был успешно разбанен.", color=0xCD853F)
try:
await banned_user.send(embed=embed)
except disnake.errors.HTTPException:
pass

await ctx.send(embed=embed, ephemeral=True)
return

embed = disnake.Embed(title="Ошибка", description=f"Пользователь {user.mention} не был найден в списке забаненных.", color=0xff0000)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -96,7 +112,7 @@ async def unban_user(self, ctx: disnake.ApplicationCommandInteraction, user: dis
@commands.has_permissions(administrator=True)
async def echo(self, ctx: disnake.ApplicationCommandInteraction, channel: disnake.TextChannel, *, message: str):
message = message.replace("-", "\n")
embed=disnake.Embed(color=0x7788ff)
embed=disnake.Embed(color=0xCD853F)
embed.add_field(name="", value=message, inline=False)
await channel.send(embed=embed)

Expand All @@ -119,14 +135,14 @@ async def join(ctx: disnake.ApplicationCommandInteraction):
channel = ctx.author.voice.channel
await channel.connect()
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Готово",
description=f"Успешно подключилась к голосовому каналу {channel.name}"
)
await ctx.send(embed=embed, ephemeral=True)

voice_channel = ctx.author.voice.channel
embed = disnake.Embed(color=0x7788ff)
embed = disnake.Embed(color=0xCD853F)
embed.add_field(name="voice", value=voice_channel.name, inline=False)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -139,7 +155,7 @@ async def join(ctx: disnake.ApplicationCommandInteraction):
async def leave(ctx: disnake.ApplicationCommandInteraction):
if not ctx.guild.voice_client:
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Ошибка",
description="Я не нахожусь в голосовом канале"
)
Expand All @@ -148,7 +164,7 @@ async def leave(ctx: disnake.ApplicationCommandInteraction):

await ctx.guild.voice_client.disconnect()
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Готово",
description="Успешно отключилась от голосового канала"
)
Expand All @@ -161,7 +177,7 @@ async def leave(ctx: disnake.ApplicationCommandInteraction):
async def stay(ctx):
if not ctx.author.voice:
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Ошибка",
description="Вы должны находиться в голосовом канале, чтобы использовать эту команду."
)
Expand All @@ -173,14 +189,14 @@ async def stay(ctx):
if voice_client and voice_client.is_connected():
await voice_client.move_to(vc)
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Готово",
description=f'Я останусь в голосовом канале "{vc.name}" до тех пор, пока меня не попросят выйти. Для этого напиши /leave.'
)
else:
voice_client = await vc.connect()
embed = disnake.Embed(
color=0x7788ff,
color=0xCD853F,
title="Готово",
description="Удачно зашла в голосовой канал."
)
Expand All @@ -199,10 +215,10 @@ async def restart(ctx: disnake.ApplicationCommandInteraction):
try:
os.execv(sys.executable, ['python'] + [arg for arg in sys.argv if arg != '--handle-sls'])
except Exception as e:
embed = disnake.Embed(title='Ошибка при перезапуске бота', color=0x7788ff)
embed = disnake.Embed(title='Ошибка при перезапуске бота', color=0xCD853F)
await ctx.send(embed=embed, ephemeral=True)
else:
embed = disnake.Embed(title='Бот перезапущен успешно', color=0x7788ff)
embed = disnake.Embed(title='Бот перезапущен успешно', color=0xCD853F)
await ctx.send(embed=embed, ephemeral=True)


Expand All @@ -218,7 +234,7 @@ async def create_role(ctx, name: str):
embed = disnake.Embed(
title=f'Роль создана',
description=f'Новая роль {role.mention} была создана!',
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -231,7 +247,7 @@ async def assign_role(ctx, role: disnake.Role, member: disnake.Member):
embed = disnake.embeds.Embed(
title='Роль добавлена',
description=f'Кисуне {member.mention} была выдана роль {role.mention}!',
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -244,7 +260,7 @@ async def remove_role(ctx, role: disnake.Role, member: disnake.Member):
embed = disnake.embeds.Embed(
title='Роль удалена',
description=f'У кисуни {member.mention} была удалена роль {role.mention}!',
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -257,7 +273,7 @@ async def set_nickname(self, ctx, member: disnake.Member, new_nickname: str):
embed = disnake.Embed(
title="Изменение никнейма :pen_ballpoint:",
description=f"Никнейм участника {member.mention} был изменен на {new_nickname}.",
color=0x7788ff
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)

Expand All @@ -277,7 +293,7 @@ async def set_color_role(ctx, role: disnake.Role, color: str = None):

await role.edit(color=color)

embed = disnake.Embed(title='Цвет изменен', color=0x7788ff)
embed = disnake.Embed(title='Цвет изменен', color=0xCD853F)
embed.add_field(name='Роль', value=role.mention)
embed.add_field(name='Цвет', value=f'#{color.value:06x}')

Expand All @@ -295,7 +311,7 @@ async def set_color_role(ctx, role: disnake.Role, color: str = None):
@commands.has_permissions(administrator=True)
async def poll(self, ctx, *, text):
await ctx.channel.purge(limit=1)
poll = disnake.Embed(description=text, colour=randint(0, 0x7788ff))
poll = disnake.Embed(description=text, colour=randint(0, 0xCD853F))
poll.timestamp = datetime.utcnow()
msg = await ctx.channel.send(embed=poll)
await msg.add_reaction("✔")
Expand All @@ -314,7 +330,7 @@ async def send(self, ctx, member: disnake.Member, *, text):

success_embed = disnake.Embed(title="Сообщение отправлено!",
description=f"Успешно отправил участнику {member.mention}",
color=0x7788ff)
color=0xCD853F)
await ctx.send(embed=success_embed, ephemeral=True)

def setup(bot: commands.Bot):
Expand Down
6 changes: 3 additions & 3 deletions cogs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ async def chat(self, inter, message: str):

if len(full_response) <= 2000:
if response.choices[0].finish_reason == 'stop' and response.choices[0].index == 0:
embed = Embed(title="ChatGPT", description=f"```{full_response}```", color=0x7788ff)
embed = Embed(title="ChatGPT", description=f"```{full_response}```", color=0xCD853F)
else:
embed = Embed(title="ChatGPT", description=full_response, color=0x7788ff)
embed = Embed(title="ChatGPT", description=full_response, color=0xCD853F)
else:
embed = Embed(title="ChatGPT", description=f"{full_response[:2000]}...\n\n[Описание обрезано из-за ограничения Discord на 2000 символов.]", color=0x7788ff)
embed = Embed(title="ChatGPT", description=f"{full_response[:2000]}...\n\n[Описание обрезано из-за ограничения Discord на 2000 символов.]", color=0xCD853F)

if not inter.responded:
await inter.send(embed=embed, ephemeral=True)
Expand Down
10 changes: 6 additions & 4 deletions cogs/econom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def daily(ctx: disnake.ApplicationCommandInteraction):
new_balance = balance + random.randint(50, 150)
c.execute('UPDATE economy SET balance = ?, last_daily = ? WHERE user_id = ?', (new_balance, int(datetime.utcnow().timestamp()), user_id))
conn.commit()
embed=disnake.Embed(color=0x7788ff)
embed=disnake.Embed(color=0xCD853F)
embed.add_field(name="Poli-coins", value="Ежедневный бонус", inline=False)
embed.add_field(name="Ты получил", value=f"{new_balance - balance} Poli-coins", inline=True)
await ctx.send(embed=embed, ephemeral=True)
Expand All @@ -55,12 +55,12 @@ async def balance(ctx: disnake.ApplicationCommandInteraction):
if not row:
c.execute('INSERT INTO economy (user_id, username, balance, last_daily) VALUES (?, ?, 0, 0)', (user_id, ctx.author.name))
conn.commit()
embed = disnake.Embed(color=0x7788ff)
embed = disnake.Embed(color=0xCD853F)
embed.add_field(name="Ваш баланс", value="На вашем счету: 0", inline=True)
await ctx.send(embed=embed, ephemeral=True)
else:
balance = row[0]
embed = disnake.Embed(color=0x7788ff)
embed = disnake.Embed(color=0xCD853F)
embed.add_field(name="Ваш баланс", value=f"На вашем счету: {balance}", inline=True)
await ctx.send(embed=embed, ephemeral=True)

Expand Down Expand Up @@ -88,7 +88,7 @@ async def heads_or_tails(ctx: disnake.ApplicationCommandInteraction, bet: int, g
c.execute('UPDATE economy SET balance = balance + ? WHERE user_id = ?', (winnings, user_id))
conn.commit()
message = f"{ctx.author.mention}, Вы выиграли {winnings} Poli-coins! Результат: {result}."
color = 0x7788ff
color = 0xCD853F
else:
c.execute('UPDATE economy SET balance = balance - ? WHERE user_id = ?', (bet, user_id))
conn.commit()
Expand Down Expand Up @@ -132,5 +132,7 @@ async def dice(ctx, bet: int):





def setup(bot: commands.Bot):
bot.add_cog(economy(bot))
Loading

0 comments on commit fa17a66

Please sign in to comment.