Add plural forms to the responses of [p]leave command (#5391)

* Improve the response of `[p]leave` command

* Update core_commands.py

* Update core_commands.py

* style?

* fix maybe

* black

* fixed typo in docstring

* aaa

* style

* Few more changes

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
krak3n 2021-12-25 05:21:17 +05:30 committed by GitHub
parent 442cad7917
commit 2c51182e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -407,7 +407,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
""" """
async def red_delete_data_for_user(self, **kwargs): async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete (Core Config is handled in a bot method ) """ """Nothing to delete (Core Config is handled in a bot method)"""
return return
@commands.command(hidden=True) @commands.command(hidden=True)
@ -1601,6 +1601,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
return await ctx.send(_("You need to specify at least one server ID.")) return await ctx.send(_("You need to specify at least one server ID."))
leaving_local_guild = not guilds leaving_local_guild = not guilds
number = len(guilds)
if leaving_local_guild: if leaving_local_guild:
guilds = (ctx.guild,) guilds = (ctx.guild,)
@ -1609,11 +1610,18 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
+ " (yes/no)" + " (yes/no)"
) )
else: else:
msg = ( if number > 1:
_("Are you sure you want me to leave these servers?") msg = (
+ " (yes/no):\n" _("Are you sure you want me to leave these servers?")
+ "\n".join(f"- {guild.name} (`{guild.id}`)" for guild in guilds) + " (yes/no):\n"
) + "\n".join(f"- {guild.name} (`{guild.id}`)" for guild in guilds)
)
else:
msg = (
_("Are you sure you want me to leave this server?")
+ " (yes/no):\n"
+ f"- {guilds[0].name} (`{guilds[0].id}`)"
)
for guild in guilds: for guild in guilds:
if guild.owner.id == ctx.me.id: if guild.owner.id == ctx.me.id:
@ -1636,9 +1644,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
if leaving_local_guild is True: if leaving_local_guild is True:
await ctx.send(_("Alright. Bye :wave:")) await ctx.send(_("Alright. Bye :wave:"))
else: else:
await ctx.send( if number > 1:
_("Alright. Leaving {number} servers...").format(number=len(guilds)) await ctx.send(
) _("Alright. Leaving {number} servers...").format(number=number)
)
else:
await ctx.send(_("Alright. Leaving one server..."))
for guild in guilds: for guild in guilds:
log.debug("Leaving guild '%s' (%s)", guild.name, guild.id) log.debug("Leaving guild '%s' (%s)", guild.name, guild.id)
await guild.leave() await guild.leave()
@ -1646,7 +1657,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
if leaving_local_guild is True: if leaving_local_guild is True:
await ctx.send(_("Alright, I'll stay then. :)")) await ctx.send(_("Alright, I'll stay then. :)"))
else: else:
await ctx.send(_("Alright, I'm not leaving those servers.")) if number > 1:
await ctx.send(_("Alright, I'm not leaving those servers."))
else:
await ctx.send(_("Alright, I'm not leaving that server."))
@commands.command() @commands.command()
@checks.is_owner() @checks.is_owner()