From e59b36fcd1b06499b89ba86609480c54b9a125a7 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sat, 6 May 2023 17:09:06 +0200 Subject: [PATCH] Improved custom channels --- cogs/custom_channels.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/cogs/custom_channels.py b/cogs/custom_channels.py index dea6828..a822f0f 100644 --- a/cogs/custom_channels.py +++ b/cogs/custom_channels.py @@ -16,14 +16,14 @@ class CustomChannels(commands.Cog): customchannel = SlashCommandGroup("customchannel", "Керування особистим каналом") @customchannel.command( - name="buy", + name="get", description="Отримати персональний текстовий канал", guild_ids=[config_get_sync("guild")], ) @option("name", description="Назва каналу") @option("reactions", description="Дозволити реакції") @option("threads", description="Дозволити гілки") - async def customchannel_buy_cmd( + async def customchannel_get_cmd( self, ctx: ApplicationContext, name: str, reactions: bool, threads: bool ): holo_user_ctx = HoloUser(ctx.user) @@ -32,7 +32,7 @@ class CustomChannels(commands.Cog): await ctx.defer() created_channel = await ctx.user.guild.create_text_channel( name=name, - reason=f"Користувач {guild_name(ctx.user)} купив канал", + reason=f"Користувач {guild_name(ctx.user)} отримав власний приватний канал", category=ds_utils.get( ctx.author.guild.categories, id=await config_get("customchannels", "categories"), @@ -117,11 +117,12 @@ class CustomChannels(commands.Cog): ) @customchannel.command( - name="refund", + name="remove", description="Відібрати канал, знищуючи його, та частково повернути кошти", guild_ids=[config_get_sync("guild")], ) - async def customchannel_refund_cmd(self, ctx: ApplicationContext): + @option("confirm", description="Підтвердження операції") + async def customchannel_remove_cmd(self, ctx: ApplicationContext, confirm: bool = False): holo_user_ctx = HoloUser(ctx.user) if holo_user_ctx.customchannel is not None: @@ -139,12 +140,21 @@ class CustomChannels(commands.Cog): ) holo_user_ctx.set("customchannel", None) return - await custom_channel.delete(reason="Повернення коштів") + if not confirm: + await ctx.respond( + embed=Embed( + title="Підтвердження не надано", + description=f"Для підтвердження операції додайте до команди параметр `confirm` зі значенням `True`.", + color=Color.fail, + ) + ) + return + await custom_channel.delete(reason="Власник запросив видалення") holo_user_ctx.set("customchannel", None) await ctx.respond( embed=Embed( title="Канал знищено", - description=f"Ви відмовились від каналу.", + description=f"Ви відмовились від каналу та видалили його.", color=Color.default, ) )