# Path: roomtools/abcs.py
# class MixedMeta(abc.ABC):
#     """
#     mypy is nice, but I need this for it to shut up about composite classes.
#     """
# 
#     def __init__(self, *args):
#         self.bot: Red
#         self._antispam: dict
#         self.antispam_intervals: list
#         self.tmpc_config: Config
#         self.ar_config: Config
#         self.qualified_name: str
# 
# Path: roomtools/checks.py
# def tmpc_active():
#     async def check(ctx: commands.Context):
#         if not ctx.guild:
#             return False
#         cog = ctx.bot.get_cog("RoomTools")
#         if TYPE_CHECKING:
#             assert isinstance(cog, RoomTools)  # nosec
#         if not cog:
#             return False
#         return await cog.tmpc_config.guild(ctx.guild).active()
# 
#     return commands.check(check)
# 
# Path: roomtools/converters.py
# class TempChannelConverter(NamedTuple):
#     name: str
#     user_limit: Optional[int] = None
# 
#     @classmethod
#     async def convert(cls, ctx: Context, argument: str):
#         arg = argument.strip()
#         try:
#             nm, ul = pattern.split(argument, maxsplit=1)
#         except ValueError:
#             return cls(arg)
# 
#         try:
#             user_limit = int(ul.strip())
#         except ValueError:
#             raise BadArgument()
# 
#         return cls(nm.strip(), user_limit)


import asyncio
import discord
from datetime import datetime, timedelta
from typing import Any, Dict
from redbot.core import checks, commands
from redbot.core.utils.antispam import AntiSpam
from .abcs import MixedMeta
from .checks import tmpc_active
from .converters import TempChannelConverter as ChannelData
    ):
        """
        Sets the category for temporary channels

        Clears it if used without specifying one
        """

        if cat is None:
            await self.tmpc_config.guild(ctx.guild).category.set(None)
            return await ctx.send("Category cleared")

        await self.tmpc_config.guild(ctx.guild).category.set(cat.id)
        await ctx.tick()

    @checks.admin_or_permissions(manage_channels=True)
    @tmpcset.command(name="usecurrentcategory")
    async def _current_category(self, ctx: commands.GuildContext, yes_or_no: bool):
        """
        Sets temporary channels to be made in the same category as the command used.

        This will only be used if a categoy is not specified with `[p]tmpcset category`

        """
        await self.tmpc_config.guild(ctx.guild).current.set(yes_or_no)
        await ctx.tick()

    async def _delayed_check(self, guild: discord.Guild):
        await asyncio.sleep(30)
        await self.tmpc_cleanup(guild)


# Path: roomtools/abcs.py
# class MixedMeta(abc.ABC):
#     """
#     mypy is nice, but I need this for it to shut up about composite classes.
#     """
# 
#     def __init__(self, *args):
#         self.bot: Red
#         self._antispam: dict
#         self.antispam_intervals: list
#         self.tmpc_config: Config
#         self.ar_config: Config
#         self.qualified_name: str
# 
# Path: roomtools/checks.py
# def tmpc_active():
#     async def check(ctx: commands.Context):
#         if not ctx.guild:
#             return False
#         cog = ctx.bot.get_cog("RoomTools")
#         if TYPE_CHECKING:
#             assert isinstance(cog, RoomTools)  # nosec
#         if not cog:
#             return False
#         return await cog.tmpc_config.guild(ctx.guild).active()
# 
#     return commands.check(check)
# 
# Path: roomtools/converters.py
# class TempChannelConverter(NamedTuple):
#     name: str
#     user_limit: Optional[int] = None
# 
#     @classmethod
#     async def convert(cls, ctx: Context, argument: str):
#         arg = argument.strip()
#         try:
#             nm, ul = pattern.split(argument, maxsplit=1)
#         except ValueError:
#             return cls(arg)
# 
#         try:
#             user_limit = int(ul.strip())
#         except ValueError:
#             raise BadArgument()
# 
#         return cls(nm.strip(), user_limit)


# Path: roomtools/tempchannels.py
import asyncio
import discord
from datetime import datetime, timedelta
from typing import Any, Dict
from redbot.core import checks, commands
from redbot.core.utils.antispam import AntiSpam
from .abcs import MixedMeta
from .checks import tmpc_active
from .converters import TempChannelConverter as ChannelData

    ):
        """
        Sets the category for temporary channels

        Clears it if used without specifying one
        """

        if cat is None:
            await self.tmpc_config.guild(ctx.guild).category.set(None)
            return await ctx.send("Category cleared")

        await self.tmpc_config.guild(ctx.guild).category.set(cat.id)
        await ctx.tick()

    @checks.admin_or_permissions(manage_channels=True)
    @tmpcset.command(name="usecurrentcategory")
    async def _current_category(self, ctx: commands.GuildContext, yes_or_no: bool):
        """
        Sets temporary channels to be made in the same category as the command used.

        This will only be used if a categoy is not specified with `[p]tmpcset category`

        """
        await self.tmpc_config.guild(ctx.guild).current.set(yes_or_no)
        await ctx.tick()

    async def _delayed_check(self, guild: discord.Guild):
        await asyncio.sleep(30)
        await self.tmpc_cleanup(guild)


    @tmpc_active()