This commit is contained in:
2024-06-23 12:05:03 +02:00
parent d168821fb5
commit f67375ff4f
12 changed files with 114 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ import logging
from discord import ApplicationContext, Embed, User, option, slash_command
from discord import utils as ds_utils
from discord.ext import commands
from libbot.pycord.classes import PycordBot
from enums.colors import Color
from modules.scheduled import scheduler
@@ -13,7 +14,7 @@ logger = logging.getLogger(__name__)
class Admin(commands.Cog):
def __init__(self, client):
def __init__(self, client: PycordBot):
self.client = client
# @slash_command(
@@ -111,9 +112,12 @@ class Admin(commands.Cog):
amount: int,
user: User,
):
if ctx.user.id in await config_get("admins"):
if ctx.user.id in self.client.config["bot"]["owners"]:
logging.info(
f"User {ctx.user.id} removed {amount} message(s) in {ctx.channel.id}"
"User %s removed %s message(s) in %s",
ctx.user.id,
amount,
ctx.channel.id,
)
await ctx.respond(
embed=Embed(description="Видаляю..."), ephemeral=True, delete_after=2.0
@@ -126,7 +130,8 @@ class Admin(commands.Cog):
)
else:
logging.warning(
f"User {guild_name(ctx.user)} tried to use /clear but permission denied"
"User %s tried to use /clear but permission denied",
guild_name(ctx.user),
)
await ctx.respond(
embed=Embed(
@@ -158,8 +163,8 @@ class Admin(commands.Cog):
)
async def reboot_cmd(self, ctx: ApplicationContext):
await ctx.defer(ephemeral=True)
if ctx.user.id in await config_get("admins"):
logging.info(f"Calling shutdown initiated by {guild_name(ctx.user)}")
if ctx.user.id in self.client.config["bot"]["owners"]:
logging.info("Calling shutdown initiated by %s", guild_name(ctx.user))
await ctx.respond(
embed=Embed(
title="Вимикаюсь...",
@@ -171,7 +176,8 @@ class Admin(commands.Cog):
exit()
else:
logging.warning(
f"User {guild_name(ctx.user)} tried to use /reboot but permission denied"
"User %s tried to use /reboot but permission denied",
guild_name(ctx.user),
)
await ctx.respond(
embed=Embed(
@@ -195,3 +201,7 @@ class Admin(commands.Cog):
color=Color.fail,
),
)
def setup(client: PycordBot):
client.add_cog(Admin(client))