|
|
@ -393,10 +393,10 @@ class GuildChannelConverter(IDConverter[discord.abc.GuildChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.abc.GuildChannel: |
|
|
|
return self._resolve_channel(ctx, argument, ctx.guild.channels, discord.abc.GuildChannel) |
|
|
|
return self._resolve_channel(ctx, argument, 'channels', discord.abc.GuildChannel) |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def _resolve_channel(ctx: Context, argument: str, iterable: Iterable[CT], type: Type[CT]) -> CT: |
|
|
|
def _resolve_channel(ctx: Context, argument: str, attribute: str, type: Type[CT]) -> CT: |
|
|
|
bot = ctx.bot |
|
|
|
|
|
|
|
match = IDConverter._get_id_match(argument) or re.match(r'<#([0-9]{15,20})>$', argument) |
|
|
@ -406,6 +406,7 @@ class GuildChannelConverter(IDConverter[discord.abc.GuildChannel]): |
|
|
|
if match is None: |
|
|
|
# not a mention |
|
|
|
if guild: |
|
|
|
iterable: Iterable[CT] = getattr(guild, attribute) |
|
|
|
result: Optional[CT] = discord.utils.get(iterable, name=argument) |
|
|
|
else: |
|
|
|
|
|
|
@ -443,7 +444,7 @@ class TextChannelConverter(IDConverter[discord.TextChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.TextChannel: |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, ctx.guild.text_channels, discord.TextChannel) |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, 'text_channels', discord.TextChannel) |
|
|
|
|
|
|
|
|
|
|
|
class VoiceChannelConverter(IDConverter[discord.VoiceChannel]): |
|
|
@ -463,7 +464,7 @@ class VoiceChannelConverter(IDConverter[discord.VoiceChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.VoiceChannel: |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, ctx.guild.voice_channels, discord.VoiceChannel) |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, 'voice_channels', discord.VoiceChannel) |
|
|
|
|
|
|
|
|
|
|
|
class StageChannelConverter(IDConverter[discord.StageChannel]): |
|
|
@ -482,7 +483,7 @@ class StageChannelConverter(IDConverter[discord.StageChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.StageChannel: |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, ctx.guild.stage_channels, discord.StageChannel) |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, 'stage_channels', discord.StageChannel) |
|
|
|
|
|
|
|
|
|
|
|
class CategoryChannelConverter(IDConverter[discord.CategoryChannel]): |
|
|
@ -502,7 +503,7 @@ class CategoryChannelConverter(IDConverter[discord.CategoryChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.CategoryChannel: |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, ctx.guild.categories, discord.CategoryChannel) |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, 'categories', discord.CategoryChannel) |
|
|
|
|
|
|
|
|
|
|
|
class StoreChannelConverter(IDConverter[discord.StoreChannel]): |
|
|
@ -521,7 +522,7 @@ class StoreChannelConverter(IDConverter[discord.StoreChannel]): |
|
|
|
""" |
|
|
|
|
|
|
|
async def convert(self, ctx: Context, argument: str) -> discord.StoreChannel: |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, ctx.guild.channels, discord.StoreChannel) |
|
|
|
return GuildChannelConverter._resolve_channel(ctx, argument, 'channels', discord.StoreChannel) |
|
|
|
|
|
|
|
|
|
|
|
class ColourConverter(Converter[discord.Colour]): |
|
|
|