From 101e977939e1c7c9a15856c9e6fc8a0e94886d03 Mon Sep 17 00:00:00 2001 From: Friesi Date: Fri, 27 Sep 2019 18:10:35 +0200 Subject: [PATCH] Change the hierarchy issue messages (#3016) * Change the hierarchy issue messages, because they are difficult to translate with the verb variable. * Fix typos * Add changelog entry * Reformatting with black --- changelog.d/admin/3016.enhance.rst | 1 + redbot/cogs/admin/admin.py | 38 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 changelog.d/admin/3016.enhance.rst diff --git a/changelog.d/admin/3016.enhance.rst b/changelog.d/admin/3016.enhance.rst new file mode 100644 index 000000000..66f393299 --- /dev/null +++ b/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. \ No newline at end of file diff --git a/redbot/cogs/admin/admin.py b/redbot/cogs/admin/admin.py index 1330fb4fe..5fb7c044c 100644 --- a/redbot/cogs/admin/admin.py +++ b/redbot/cogs/admin/admin.py @@ -19,20 +19,34 @@ GENERIC_FORBIDDEN = _( " 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" @@ -111,9 +125,7 @@ class Admin(commands.Cog): 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: @@ -128,9 +140,7 @@ class Admin(commands.Cog): 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: @@ -156,9 +166,7 @@ class Admin(commands.Cog): # 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() @@ -176,9 +184,7 @@ class Admin(commands.Cog): # 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()