Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the hierarchy issue messages #3016

Merged
merged 4 commits into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/admin/3016.enhance.rst
@@ -0,0 +1 @@
Add custom issue messages for adding and removing roles, this makes it easier to create translations.
38 changes: 22 additions & 16 deletions redbot/cogs/admin/admin.py
Expand Up @@ -19,20 +19,34 @@
" Your command failed to successfully complete."
)

HIERARCHY_ISSUE = _(
"I tried to {verb} {role.name} to {member.display_name} but that role"
HIERARCHY_ISSUE_ADD = _(
"I tried to add {role.name} to {member.display_name} but that role"
" is higher than my highest role in the Discord hierarchy so I was"
" unable to successfully add it. Please give me a higher role and "
"try again."
)

USER_HIERARCHY_ISSUE = _(
"I tried to {verb} {role.name} to {member.display_name} but that role"
HIERARCHY_ISSUE_REMOVE = _(
"I tried to remove {role.name} from {member.display_name} but that role"
" is higher than my highest role in the Discord hierarchy so I was"
" unable to successfully remove it. Please give me a higher role and "
"try again."
)

USER_HIERARCHY_ISSUE_ADD = _(
"I tried to add {role.name} to {member.display_name} but that role"
" is higher than your highest role in the Discord hierarchy so I was"
" unable to successfully add it. Please get a higher role and "
"try again."
)

USER_HIERARCHY_ISSUE_REMOVE = _(
"I tried to remove {role.name} from {member.display_name} but that role"
" is higher than your highest role in the Discord hierarchy so I was"
" unable to successfully remove it. Please get a higher role and "
"try again."
)

ROLE_USER_HIERARCHY_ISSUE = _(
"I tried to edit {role.name} but that role"
" is higher than your highest role in the Discord hierarchy so I was"
Expand Down Expand Up @@ -111,9 +125,7 @@ async def _addrole(self, ctx: commands.Context, member: discord.Member, role: di
await member.add_roles(role)
except discord.Forbidden:
if not self.pass_hierarchy_check(ctx, role):
await self.complain(
ctx, T_(HIERARCHY_ISSUE), role=role, member=member, verb=_("add")
)
await self.complain(ctx, T_(HIERARCHY_ISSUE_ADD), role=role, member=member)
else:
await self.complain(ctx, T_(GENERIC_FORBIDDEN))
else:
Expand All @@ -128,9 +140,7 @@ async def _removerole(self, ctx: commands.Context, member: discord.Member, role:
await member.remove_roles(role)
except discord.Forbidden:
if not self.pass_hierarchy_check(ctx, role):
await self.complain(
ctx, T_(HIERARCHY_ISSUE), role=role, member=member, verb=_("remove")
)
await self.complain(ctx, T_(HIERARCHY_ISSUE_REMOVE), role=role, member=member)
else:
await self.complain(ctx, T_(GENERIC_FORBIDDEN))
else:
Expand All @@ -156,9 +166,7 @@ async def addrole(
# noinspection PyTypeChecker
await self._addrole(ctx, user, rolename)
else:
await self.complain(
ctx, T_(USER_HIERARCHY_ISSUE), member=user, role=rolename, verb=_("add")
)
await self.complain(ctx, T_(USER_HIERARCHY_ISSUE_ADD), member=user, role=rolename)

@commands.command()
@commands.guild_only()
Expand All @@ -176,9 +184,7 @@ async def removerole(
# noinspection PyTypeChecker
await self._removerole(ctx, user, rolename)
else:
await self.complain(
ctx, T_(USER_HIERARCHY_ISSUE), member=user, role=rolename, verb=_("remove")
)
await self.complain(ctx, T_(USER_HIERARCHY_ISSUE_REMOVE), member=user, role=rolename)

@commands.group()
@commands.guild_only()
Expand Down