def convert(self, ctx, argument):
guild = ctx.guild
if not guild:
raise commands.NoPrivateMessage()
# Let ID's and mentions take priority
match = self._get_id_match(argument) or re.match(r'<@&([0-9]+)>$', argument)
if match:
predicate = lambda r, id=int(match.group(1)): r.id == id
elif self.case_sensitive:
predicate = lambda r: r.name == argument
else:
predicate = lambda r, arg=argument.lower(): r.name.lower() == arg
return await ctx.disambiguate(list(filter(predicate, guild.roles)))
评论列表
文章目录