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

@ -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."))
leaving_local_guild = not guilds
number = len(guilds)
if leaving_local_guild:
guilds = (ctx.guild,)
@ -1609,11 +1610,18 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
+ " (yes/no)"
)
else:
if number > 1:
msg = (
_("Are you sure you want me to leave these servers?")
+ " (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:
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:
await ctx.send(_("Alright. Bye :wave:"))
else:
if number > 1:
await ctx.send(
_("Alright. Leaving {number} servers...").format(number=len(guilds))
_("Alright. Leaving {number} servers...").format(number=number)
)
else:
await ctx.send(_("Alright. Leaving one server..."))
for guild in guilds:
log.debug("Leaving guild '%s' (%s)", guild.name, guild.id)
await guild.leave()
@ -1646,7 +1657,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
if leaving_local_guild is True:
await ctx.send(_("Alright, I'll stay then. :)"))
else:
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()
@checks.is_owner()