def _parse_roles(self, ctx: Context, roles: str, is_primary: int = 0) -> List[Tuple]:
roles = roles.rstrip(", \t\n\r")
roles_arr = roles.split(",")
alias = None
rows = []
for r in roles_arr:
if "=" in r:
role, alias = r.split("=")
role = role.strip(" \t\n\r\"'")
alias = alias.strip(" \t\n\r\"'")
else:
role = r.strip(" \t\n\r\"'")
try:
role_conv = RoleConverter(ctx, role).convert()
except BadArgument as e:
# Unable to convert this role
msg = e.args[0]
print(msg)
await self.bot.say("Couldn't find role `{}` on this server".format(role))
continue
rows.append((role_conv, alias, is_primary))
return rows
评论列表
文章目录