6 Commits

Author SHA1 Message Date
3010dc02bc Merge pull request 'v0.1.0-rc.3' (#15) from dev into main
Reviewed-on: #15
2024-12-16 22:08:22 +02:00
kku
ccf7e06e67 Added indirect dependencies for WaifuPicsPython 2024-12-16 21:04:47 +01:00
kku
af04a7dce6 Changed scheduler declaration 2024-12-16 20:59:10 +01:00
kku
ef4e42fff0 Improved error handling 2024-12-16 20:49:58 +01:00
4afcbc93d5 Merge pull request 'Fixed minor issues' (#6) from dev into main
Reviewed-on: #6
2024-06-23 13:14:08 +03:00
72ccaa04a4 Merge pull request 'v0.1.0-rc.1' (#5) from dev into main
Reviewed-on: #5
2024-06-23 13:06:12 +03:00
6 changed files with 44 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ from libbot.pycord.classes import PycordBot
from libbot.sync import config_get as sync_config_get
from enums import Color
from modules.scheduled import scheduler
from modules.scheduler import scheduler
from modules.utils_sync import guild_name
from modules.waifu_pics import waifu_pics

View File

@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Union
import logging
from typing import Any, Dict, Union
from discord import ApplicationContext, Embed, option, TextChannel
from discord import ApplicationContext, Embed, option, TextChannel, Role
from discord import utils as ds_utils
from discord.abc import GuildChannel
from discord.commands import SlashCommandGroup
@@ -14,6 +15,8 @@ from enums import Color
from modules.database import col_users
from modules.utils_sync import guild_name
logger = logging.getLogger(__name__)
class CustomChannels(commands.Cog):
def __init__(self, client: PycordBot):
@@ -37,11 +40,23 @@ class CustomChannels(commands.Cog):
@option("name", description="Назва каналу")
@option("reactions", description="Дозволити реакції")
@option("threads", description="Дозволити гілки")
async def customchannel_get_cmd(
async def custom_channel_get_cmd(
self, ctx: ApplicationContext, name: str, reactions: bool, threads: bool
) -> None:
holo_user_ctx: HoloUser = HoloUser(ctx.user)
# Return if the user is using the command outside of a guild
if not hasattr(ctx.author, "guild"):
await ctx.defer(ephemeral=True)
await ctx.respond(
embed=Embed(
title="Помилка виконання",
description="Виконання за межами сервера не є можливим.",
color=Color.FAIL,
)
)
return
# Return if the user already has a custom channel
if holo_user_ctx.customchannel is not None:
await ctx.defer(ephemeral=True)
@@ -91,14 +106,19 @@ class CustomChannels(commands.Cog):
)
)
bots: List[Dict[str, Any]] = await config_get("bots")
bots: Dict[str, Any] = await config_get("bots")
for bot in bots:
await created_channel.set_permissions(
ds_utils.get(ctx.user.guild.roles, id=bots[bot]["role"]),
view_channel=False,
role: Union[Role, None] = ds_utils.get(
ctx.user.guild.roles, id=bots[bot]["role"]
)
if role is not None:
await created_channel.set_permissions(
role,
view_channel=False,
)
@custom_channel_group.command(
name="edit",
description="Змінити параметри особистого каналу",
@@ -107,7 +127,7 @@ class CustomChannels(commands.Cog):
@option("name", description="Назва каналу")
@option("reactions", description="Дозволити реакції")
@option("threads", description="Дозволити гілки")
async def customchannel_edit_cmd(
async def custom_channel_edit_cmd(
self, ctx: ApplicationContext, name: str, reactions: bool, threads: bool
) -> None:
holo_user_ctx: HoloUser = HoloUser(ctx.user)
@@ -150,7 +170,7 @@ class CustomChannels(commands.Cog):
guild_ids=[sync_config_get("guild")],
)
@option("confirm", description="Підтвердження операції")
async def customchannel_remove_cmd(
async def custom_channel_remove_cmd(
self, ctx: ApplicationContext, confirm: bool = False
) -> None:
holo_user_ctx: HoloUser = HoloUser(ctx.user)
@@ -200,7 +220,7 @@ class CustomChannels(commands.Cog):
await holo_user_ctx.set("customchannel", None)
if ctx.channel_id != custom_channel.id:
try:
await ctx.respond(
embed=Embed(
title="Канал знищено",
@@ -208,6 +228,10 @@ class CustomChannels(commands.Cog):
color=Color.DEFAULT,
)
)
except Exception as exc:
logger.warning(
"Could not send a custom channel removal confirmation due to: %s", exc
)
def setup(client: PycordBot) -> None:

View File

@@ -7,7 +7,7 @@ from libbot import config_get
from libbot.sync import config_get as sync_config_get
from modules.client import client
from modules.scheduled import scheduler
from modules.scheduler import scheduler
logging.basicConfig(
level=logging.INFO,

View File

@@ -1,8 +1,10 @@
from discord import Intents
from libbot.pycord.classes import PycordBot
from modules.scheduler import scheduler
intents: Intents = Intents().all()
intents.members = True
client: PycordBot = PycordBot(intents=intents)
client: PycordBot = PycordBot(intents=intents, scheduler=scheduler)

View File

@@ -1,5 +1,9 @@
# Waifu pics related dependencies (not listed directly by waifupics)
aiohttp>=3.10.0
requests>=2.32.2
aiofiles~=24.1.0
apscheduler~=3.11.0
apscheduler>=3.10.0
async_pymongo==0.1.11
libbot[speed,pycord]==3.2.3
ujson~=5.10.0