# Path: channelredirect/converters.py
# class CogOrCOmmand(NamedTuple):
#     stype: str
#     obj: str
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         # mypy doesn't do type narrowing for the walrus yet
#         if com := ctx.bot.get_command(arg):
#             assert com, "mypy"  # nosec
#             return cls("command", com.qualified_name)
#         if cog := ctx.bot.get_cog(arg):
#             assert cog, "mypy"  # nosec
#             return cls("cog", cog.__class__.__name__)
#         raise commands.BadArgument('Cog or Command "{arg}" not found.'.format(arg=arg))
# 
# class CommandConverter(NamedTuple):
#     com: commands.Command
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         ret = ctx.bot.get_command(arg)
#         if ret:
#             return cls(ret)
#         raise commands.BadArgument('Command "{arg}" not found.'.format(arg=arg))
# 
# class TrinaryBool(NamedTuple):
#     state: Union[bool, None]
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         try:
#             ret = {"allow": True, "deny": False, "clear": None}[arg.lower()]
#         except KeyError:
#             raise commands.BadArgument(
#                 "Was expecting one of `allow`, `deny`, or `clear`, got {arg}".format(
#                     arg=arg
#                 )
#             )
#         else:
#             return cls(ret)


import asyncio
import contextlib
import discord
from typing import Set
from redbot.core import checks, commands
from redbot.core.config import Config
from .converters import CogOrCOmmand, CommandConverter, TrinaryBool

    async def before_invoke_hook(self, ctx: commands.Context):

        if await self.is_redirect_immune(ctx):
            return True

        allowed_chans = await self.get_allowed_channels(ctx)

        if ctx.channel not in allowed_chans and not isinstance(
            ctx.command, commands.commands._AlwaysAvailableCommand
        ):
            chan_mentions = ", ".join(c.mention for c in allowed_chans)
            await ctx.send(
                f"{ctx.author.mention} This command is only available in {chan_mentions}",
                delete_after=30,
            )
            raise commands.CheckFailure()
        else:
            return True

    @commands.guild_only()
    @checks.admin_or_permissions(manage_guild=True)
    @commands.group(name="redirectset")
    async def rset(self, ctx):
        """
        Setting for channel redirection.
        """
        pass

    @rset.command(name="showsettings")

# Path: channelredirect/converters.py
# class CogOrCOmmand(NamedTuple):
#     stype: str
#     obj: str
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         # mypy doesn't do type narrowing for the walrus yet
#         if com := ctx.bot.get_command(arg):
#             assert com, "mypy"  # nosec
#             return cls("command", com.qualified_name)
#         if cog := ctx.bot.get_cog(arg):
#             assert cog, "mypy"  # nosec
#             return cls("cog", cog.__class__.__name__)
#         raise commands.BadArgument('Cog or Command "{arg}" not found.'.format(arg=arg))
# 
# class CommandConverter(NamedTuple):
#     com: commands.Command
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         ret = ctx.bot.get_command(arg)
#         if ret:
#             return cls(ret)
#         raise commands.BadArgument('Command "{arg}" not found.'.format(arg=arg))
# 
# class TrinaryBool(NamedTuple):
#     state: Union[bool, None]
# 
#     @classmethod
#     async def convert(cls, ctx: commands.Context, arg: str):
#         try:
#             ret = {"allow": True, "deny": False, "clear": None}[arg.lower()]
#         except KeyError:
#             raise commands.BadArgument(
#                 "Was expecting one of `allow`, `deny`, or `clear`, got {arg}".format(
#                     arg=arg
#                 )
#             )
#         else:
#             return cls(ret)


# Path: channelredirect/redirect.py
import asyncio
import contextlib
import discord
from typing import Set
from redbot.core import checks, commands
from redbot.core.config import Config
from .converters import CogOrCOmmand, CommandConverter, TrinaryBool


    async def before_invoke_hook(self, ctx: commands.Context):

        if await self.is_redirect_immune(ctx):
            return True

        allowed_chans = await self.get_allowed_channels(ctx)

        if ctx.channel not in allowed_chans and not isinstance(
            ctx.command, commands.commands._AlwaysAvailableCommand
        ):
            chan_mentions = ", ".join(c.mention for c in allowed_chans)
            await ctx.send(
                f"{ctx.author.mention} This command is only available in {chan_mentions}",
                delete_after=30,
            )
            raise commands.CheckFailure()
        else:
            return True

    @commands.guild_only()
    @checks.admin_or_permissions(manage_guild=True)
    @commands.group(name="redirectset")
    async def rset(self, ctx):
        """
        Setting for channel redirection.
        """
        pass

    @rset.command(name="showsettings")

    async def rest_show_settings(self, ctx, command: CommandConverter = None):