def role_by_substring(ctx: commands.Context, substring: str):
"""This searches for a role by substrings."""
try:
return await roleconverter.convert(ctx, substring)
except commands.CommandError:
pass
substring = substring.lower()
for role in ctx.guild.roles:
if substring in role.name.lower():
return role
raise commands.BadArgument(f"No role with substring `{substring}` was found.")
评论列表
文章目录