mirror of
https://github.com/brandons209/Red-bot-Cogs.git
synced 2024-06-02 10:34:54 +12:00
have exceptions always return role lists as ids
This commit is contained in:
parent
9329e2a8de
commit
380356bff5
|
@ -895,14 +895,14 @@ class RoleManagement(
|
||||||
except MissingRequirementsException as e:
|
except MissingRequirementsException as e:
|
||||||
msg = ""
|
msg = ""
|
||||||
if e.miss_all:
|
if e.miss_all:
|
||||||
roles = [r for r in ctx.guild.roles if r in e.miss_all]
|
roles = [r.name for r in ctx.guild.roles if r.id in e.miss_all]
|
||||||
msg += f"You need all of these roles in order to get this role: {humanize_list(roles)}\n"
|
msg += f"You need all of these roles in order to get this role: {humanize_list(roles)}\n"
|
||||||
if e.miss_any:
|
if e.miss_any:
|
||||||
roles = [r for r in ctx.guild.roles if r in e.miss_any]
|
roles = [r.name for r in ctx.guild.roles if r.id in e.miss_any]
|
||||||
msg += f"You need one of these roles in order to get this role: {humanize_list(roles)}\n"
|
msg += f"You need one of these roles in order to get this role: {humanize_list(roles)}\n"
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
except ConflictingRoleException as e:
|
except ConflictingRoleException as e:
|
||||||
roles = [r for r in ctx.guild.roles if r in e.conflicts]
|
roles = [r.name for r in ctx.guild.roles if r.id in e.conflicts]
|
||||||
plural = "are" if len(roles) > 1 else "is"
|
plural = "are" if len(roles) > 1 else "is"
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
||||||
|
@ -965,15 +965,15 @@ class RoleManagement(
|
||||||
except MissingRequirementsException as e:
|
except MissingRequirementsException as e:
|
||||||
msg = ""
|
msg = ""
|
||||||
if e.miss_all:
|
if e.miss_all:
|
||||||
roles = [r for r in ctx.guild.roles if r in e.miss_all]
|
roles = [r.name for r in ctx.guild.roles if r.id in e.miss_all]
|
||||||
msg += f"You need all of these roles in order to get this role: {humanize_list(roles)}\n"
|
msg += f"You need all of these roles in order to get this role: {humanize_list(roles)}\n"
|
||||||
if e.miss_any:
|
if e.miss_any:
|
||||||
roles = [r for r in ctx.guild.roles if r in e.miss_any]
|
roles = [r.name for r in ctx.guild.roles if r.id in e.miss_any]
|
||||||
msg += f"You need one of these roles in order to get this role: {humanize_list(roles)}\n"
|
msg += f"You need one of these roles in order to get this role: {humanize_list(roles)}\n"
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
except ConflictingRoleException as e:
|
except ConflictingRoleException as e:
|
||||||
print(e.conflicts)
|
print(e.conflicts)
|
||||||
roles = [r for r in ctx.guild.roles if r in e.conflicts]
|
roles = [r.name for r in ctx.guild.roles if r in e.conflicts]
|
||||||
plural = "are" if len(roles) > 1 else "is"
|
plural = "are" if len(roles) > 1 else "is"
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
f"You have {humanize_list(roles)}, which you are not allowed to remove and {plural} exclusive to: {role.name}"
|
||||||
|
|
|
@ -174,10 +174,10 @@ class UtilMixin(MixinMeta):
|
||||||
ex = []
|
ex = []
|
||||||
for ex_roles in ex_data:
|
for ex_roles in ex_data:
|
||||||
ex.extend(ex_roles)
|
ex.extend(ex_roles)
|
||||||
conflicts: List[discord.Role] = [r for r in who.roles if r.id in ex]
|
conflicts: List[int] = [r.id for r in who.roles if r.id in ex]
|
||||||
|
|
||||||
for r in conflicts:
|
for r in conflicts:
|
||||||
if not data.get(r.id, {}).get("self_removable", False):
|
if not data.get(r, {}).get("self_removable", False):
|
||||||
raise ConflictingRoleException(conflicts=conflicts)
|
raise ConflictingRoleException(conflicts=conflicts)
|
||||||
return conflicts
|
return conflicts
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue