Closes #2
This commit is contained in:
@@ -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))
|
||||
|
@@ -2,6 +2,7 @@ import logging
|
||||
|
||||
from discord import Cog, Message
|
||||
from discord.ext import commands
|
||||
from libbot.pycord.classes import PycordBot
|
||||
|
||||
from modules.database import col_analytics
|
||||
|
||||
@@ -9,7 +10,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Analytics(commands.Cog):
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
|
||||
@Cog.listener()
|
||||
@@ -54,3 +55,7 @@ class Analytics(commands.Cog):
|
||||
"attachments": attachments,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
client.add_cog(Analytics(client))
|
||||
|
@@ -3,6 +3,7 @@ from discord import utils as ds_utils
|
||||
from discord.abc import GuildChannel
|
||||
from discord.commands import SlashCommandGroup
|
||||
from discord.ext import commands
|
||||
from libbot.pycord.classes import PycordBot
|
||||
|
||||
from classes.holo_user import HoloUser
|
||||
from enums.colors import Color
|
||||
@@ -12,7 +13,7 @@ from modules.utils_sync import config_get_sync, guild_name
|
||||
|
||||
|
||||
class CustomChannels(commands.Cog):
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
@@ -80,7 +81,7 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Помилка виконання",
|
||||
description=f"У вас вже є особистий канал.\nДля редагування каналу є `/customchannel edit` або просто відкрийте меню керування вашим каналом.",
|
||||
description="У вас вже є особистий канал.\nДля редагування каналу є `/customchannel edit` або просто відкрийте меню керування вашим каналом.",
|
||||
color=Color.fail,
|
||||
)
|
||||
)
|
||||
@@ -105,7 +106,7 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Канал не знайдено",
|
||||
description=f"Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||
description="Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||
color=Color.fail,
|
||||
)
|
||||
)
|
||||
@@ -146,7 +147,7 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Канал не знайдено",
|
||||
description=f"Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||
description="Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||
color=Color.fail,
|
||||
)
|
||||
)
|
||||
@@ -156,7 +157,7 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Підтвердження не надано",
|
||||
description=f"Для підтвердження операції додайте до команди параметр `confirm` зі значенням `True`.",
|
||||
description="Для підтвердження операції додайте до команди параметр `confirm` зі значенням `True`.",
|
||||
color=Color.fail,
|
||||
)
|
||||
)
|
||||
@@ -166,7 +167,7 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Канал знищено",
|
||||
description=f"Ви відмовились від каналу та видалили його.",
|
||||
description="Ви відмовились від каналу та видалили його.",
|
||||
color=Color.default,
|
||||
)
|
||||
)
|
||||
@@ -175,7 +176,11 @@ class CustomChannels(commands.Cog):
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
title="Помилка виконання",
|
||||
description=f"У вас немає особистого каналу.",
|
||||
description="У вас немає особистого каналу.",
|
||||
color=Color.fail,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
client.add_cog(CustomChannels(client))
|
||||
|
26
cogs/data.py
26
cogs/data.py
@@ -7,8 +7,9 @@ from discord import ApplicationContext, Embed, File, option
|
||||
from discord import utils as ds_utils
|
||||
from discord.commands import SlashCommandGroup
|
||||
from discord.ext import commands
|
||||
from classes.holo_user import HoloUser
|
||||
from libbot.pycord.classes import PycordBot
|
||||
|
||||
from classes.holo_user import HoloUser
|
||||
from enums.colors import Color
|
||||
from modules.database import col_users
|
||||
from modules.utils import config_get
|
||||
@@ -18,7 +19,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Data(commands.Cog):
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
|
||||
data = SlashCommandGroup("data", "Керування даними користувачів")
|
||||
@@ -34,11 +35,11 @@ class Data(commands.Cog):
|
||||
async def data_export_cmd(self, ctx: ApplicationContext, kind: str):
|
||||
await ctx.defer()
|
||||
holo_user = HoloUser(ctx.author)
|
||||
if (ctx.user.id in await config_get("admins")) or (
|
||||
if (ctx.user.id in self.client.config["bot"]["owners"]) or (
|
||||
await holo_user.is_council(ctx.author)
|
||||
):
|
||||
logging.info(
|
||||
f"Moderator {guild_name(ctx.user)} exported current users list"
|
||||
"Moderator %s exported current users list", guild_name(ctx.user)
|
||||
)
|
||||
makedirs("tmp", exist_ok=True)
|
||||
uuid = str(uuid4())
|
||||
@@ -63,7 +64,8 @@ class Data(commands.Cog):
|
||||
)
|
||||
else:
|
||||
logging.info(
|
||||
f"User {guild_name(ctx.user)} tried to use /export but permission denied"
|
||||
"User %s tried to use /export but permission denied",
|
||||
guild_name(ctx.user),
|
||||
)
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
@@ -99,11 +101,12 @@ class Data(commands.Cog):
|
||||
async def data_migrate_cmd(self, ctx: ApplicationContext, kind: str):
|
||||
await ctx.defer()
|
||||
holo_user = HoloUser(ctx.author)
|
||||
if (ctx.user.id in await config_get("admins")) or (
|
||||
if (ctx.user.id in self.client.config["bot"]["owners"]) or (
|
||||
await holo_user.is_council(ctx.author)
|
||||
):
|
||||
logging.info(
|
||||
f"Moderator {guild_name(ctx.user)} started migration of all members to the database"
|
||||
"Moderator %s started migration of all members to the database",
|
||||
guild_name(ctx.user),
|
||||
)
|
||||
|
||||
if kind == "Користувачі":
|
||||
@@ -121,7 +124,7 @@ class Data(commands.Cog):
|
||||
|
||||
col_users.insert_one(document=user)
|
||||
logging.info(
|
||||
f"Added DB record for user {member.id} during migration"
|
||||
"Added DB record for user %s during migration", member.id
|
||||
)
|
||||
|
||||
await ctx.respond(
|
||||
@@ -133,7 +136,8 @@ class Data(commands.Cog):
|
||||
)
|
||||
else:
|
||||
logging.info(
|
||||
f"User {guild_name(ctx.user)} tried to use /migrate but permission denied"
|
||||
"User %s tried to use /migrate but permission denied",
|
||||
guild_name(ctx.user),
|
||||
)
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
@@ -157,3 +161,7 @@ class Data(commands.Cog):
|
||||
color=Color.fail,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
client.add_cog(Data(client))
|
||||
|
15
cogs/fun.py
15
cogs/fun.py
@@ -2,6 +2,7 @@ import logging
|
||||
|
||||
from discord import ApplicationContext, Embed, User, option, slash_command
|
||||
from discord.ext import commands
|
||||
from libbot.pycord.classes import PycordBot
|
||||
from WaifuPicsPython import WaifuAsync
|
||||
|
||||
from modules.utils import config_get
|
||||
@@ -13,7 +14,7 @@ wafiu_pics = WaifuAsync()
|
||||
|
||||
|
||||
class Fun(commands.Cog):
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
|
||||
@slash_command(
|
||||
@@ -36,7 +37,13 @@ class Fun(commands.Cog):
|
||||
image = await wafiu_pics.sfw(action)
|
||||
|
||||
logger.info(
|
||||
f"User {guild_name(ctx.user)} ({ctx.user.id}) {action_verb} {guild_name(user)} ({user.id}) with image {image}"
|
||||
"User %s (%s) %s %s (%s) with image %s",
|
||||
guild_name(ctx.user),
|
||||
ctx.user.id,
|
||||
action_verb,
|
||||
guild_name(user),
|
||||
user.id,
|
||||
image,
|
||||
)
|
||||
|
||||
embed = Embed(
|
||||
@@ -46,3 +53,7 @@ class Fun(commands.Cog):
|
||||
embed.set_image(url=image)
|
||||
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
client.add_cog(Fun(client))
|
||||
|
@@ -1,13 +1,14 @@
|
||||
from discord import Member, Message
|
||||
from discord import utils as ds_utils
|
||||
from discord.ext import commands
|
||||
from libbot.pycord.classes import PycordBot
|
||||
|
||||
from modules.database import col_users
|
||||
from modules.utils import config_get
|
||||
|
||||
|
||||
class Logger(commands.Cog):
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
@@ -60,3 +61,7 @@ class Logger(commands.Cog):
|
||||
user[key] = defaults[key]
|
||||
|
||||
col_users.insert_one(document=user)
|
||||
|
||||
|
||||
def setup(client: PycordBot):
|
||||
client.add_cog(Logger(client))
|
||||
|
Reference in New Issue
Block a user