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 Aug 2, 2023
1 parent fa17a66 commit 5019b3d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
38 changes: 10 additions & 28 deletions cogs/admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from random import randint, random
from disnake import Option
import sqlite3
import os
import sys
from datetime import datetime


Expand Down Expand Up @@ -46,15 +44,16 @@ async def kick_user(self, ctx: disnake.ApplicationCommandInteraction, user: disn


@commands.slash_command(name='clear', description='Очистить чат')
async def clear(self, ctx: disnake.ApplicationCommandInteraction, amount: int):
async def clear(self, ctx, amount: int):
if not ctx.author.guild_permissions.manage_messages:
await ctx.send('Эта команда доступна только для администраторов.')
return
raise commands.CheckFailure

if amount > 1000:
await ctx.send('Кискис нельзя удалить больше 1000 сообщений за раз.')
return

deleted = await ctx.channel.purge(limit=amount)
embed=disnake.Embed(color=0xCD853F)
embed = disnake.Embed(color=0xCD853F)
embed.add_field(name="Очистила чат", value=f"Удалила {len(deleted)} сообщений 😊", inline=False)
await ctx.send(embed=embed, ephemeral=True)

Expand Down Expand Up @@ -204,28 +203,6 @@ async def stay(ctx):
await ctx.send(embed=embed, ephemeral=True)





@commands.slash_command(name='restart', description='Перезапустить бота')
@commands.has_permissions(administrator=True)
async def restart(ctx: disnake.ApplicationCommandInteraction):
await ctx.response.defer()

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=0xCD853F)
await ctx.send(embed=embed, ephemeral=True)
else:
embed = disnake.Embed(title='Бот перезапущен успешно', color=0xCD853F)
await ctx.send(embed=embed, ephemeral=True)






@commands.slash_command(name='create_role', description='Создание новой роли')
@commands.has_permissions(administrator=True)
async def create_role(ctx, name: str):
Expand Down Expand Up @@ -333,5 +310,10 @@ async def send(self, ctx, member: disnake.Member, *, text):
color=0xCD853F)
await ctx.send(embed=success_embed, ephemeral=True)






def setup(bot: commands.Bot):
bot.add_cog(admins(bot))
6 changes: 4 additions & 2 deletions cogs/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ async def on_slash_command_error(self, interaction: disnake.Interaction, error):


@commands.Cog.listener()
async def on_command_error(self, ctx, error):
async def on_slash_command_error(self, ctx, error):
if isinstance(error, commands.CheckFailure):
embed = disnake.Embed(
title="Ошибка доступа",
description="Эта команда доступна только для администраторов.",
color=0xCD853F
)
await ctx.send(embed=embed, ephemeral=True)
await ctx.response.send_message(embed=embed, ephemeral=True)





Expand Down
4 changes: 2 additions & 2 deletions cogs/infobots.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def __init__(self, bot):
@commands.slash_command(name= "bot", description="Информация о Polina bot")
async def bot(self, ctx):
info=disnake.Embed(title = ":robot: Информация о боте", description = f"Информация об **Polina bot**", colour=randint(0, 0xffffff))
info.add_field(name = ":bearded_person: Разработчик:", value = "`П͓̽р͓̽о͓̽в͓̽а͓̽й͓̽д͓̽е͓̽р͓̽#6666`")
info.add_field(name = ":bearded_person: Разработчик:", value = "`python_maksim_dev`")
info.add_field(name = ":ledger: Моя библиотека:", value="Disnake", inline=False)
info.add_field(name = ":floppy_disk: Моя версия:", value = "`v3.5`", inline=False)
info.add_field(name = ":floppy_disk: Моя версия:", value = "`v3.5.1`", inline=False)
info.add_field(name = "🔗 Приглашение:", value = f"[Нажми](https://discord.com/api/oauth2/authorize?client_id=1023602153694183475&permissions=8&scope=bot)", inline = True)
info.add_field(name = "⚙️ Команд:", value = f"{len(self.bot.slash_commands)}")
info.add_field(name = "📊 Кол-во гильдий:", value = f"{len(self.bot.guilds)}")
Expand Down

0 comments on commit 5019b3d

Please sign in to comment.