def convert(self, ctx, argument):
bot = ctx.bot
match = self._get_id_match(argument) or re.match(r'<#([0-9]+)>$', argument)
result = None
guild = ctx.guild
if match is not None:
return await super().convert(ctx, argument)
else:
if self.case_sensitive:
def check(c):
return isinstance(c, discord.TextChannel) and c.name == argument
else:
# not a mention
lowered = argument.lower()
def check(c):
return isinstance(c, discord.TextChannel) and c.name.lower() == lowered
if guild:
result = list(filter(check, guild.text_channels))
transform = str
else:
result = list(filter(check, bot.get_all_channels()))
transform = '{0} (Server: {0.guild})'
return await ctx.disambiguate(result, transform)
评论列表
文章目录