mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
[Utils] Add humanize_number() function to chat formatting (#2836)
This adds babel as a dependency, and also includes `redbot.core.i18n.get_babel_locale()`
This commit is contained in:
@@ -8,6 +8,7 @@ import discord
|
||||
from redbot.core import checks, commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.i18n import Translator, cog_i18n
|
||||
from redbot.core.utils.chat_formatting import humanize_number
|
||||
from redbot.core.utils.mod import slow_deletion, mass_purge
|
||||
from redbot.core.utils.predicates import MessagePredicate
|
||||
from .converters import RawMessageIds
|
||||
@@ -39,7 +40,9 @@ class Cleanup(commands.Cog):
|
||||
return True
|
||||
|
||||
prompt = await ctx.send(
|
||||
_("Are you sure you want to delete {number} messages? (y/n)").format(number=number)
|
||||
_("Are you sure you want to delete {number} messages? (y/n)").format(
|
||||
number=humanize_number(number)
|
||||
)
|
||||
)
|
||||
response = await ctx.bot.wait_for("message", check=MessagePredicate.same_context(ctx))
|
||||
|
||||
@@ -152,7 +155,11 @@ class Cleanup(commands.Cog):
|
||||
to_delete.append(ctx.message)
|
||||
|
||||
reason = "{}({}) deleted {} messages containing '{}' in channel {}.".format(
|
||||
author.name, author.id, len(to_delete), text, channel.id
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_us"),
|
||||
text,
|
||||
channel.id,
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -208,7 +215,14 @@ class Cleanup(commands.Cog):
|
||||
reason = (
|
||||
"{}({}) deleted {} messages "
|
||||
" made by {}({}) in channel {}."
|
||||
"".format(author.name, author.id, len(to_delete), member or "???", _id, channel.name)
|
||||
"".format(
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
member or "???",
|
||||
_id,
|
||||
channel.name,
|
||||
)
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -240,7 +254,10 @@ class Cleanup(commands.Cog):
|
||||
)
|
||||
|
||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
||||
author.name, author.id, len(to_delete), channel.name
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
channel.name,
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -277,7 +294,10 @@ class Cleanup(commands.Cog):
|
||||
to_delete.append(ctx.message)
|
||||
|
||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
||||
author.name, author.id, len(to_delete), channel.name
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
channel.name,
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -319,7 +339,10 @@ class Cleanup(commands.Cog):
|
||||
)
|
||||
to_delete.append(ctx.message)
|
||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
||||
author.name, author.id, len(to_delete), channel.name
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
channel.name,
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -420,7 +443,12 @@ class Cleanup(commands.Cog):
|
||||
reason = (
|
||||
"{}({}) deleted {} "
|
||||
" command messages in channel {}."
|
||||
"".format(author.name, author.id, len(to_delete), channel.name)
|
||||
"".format(
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
channel.name,
|
||||
)
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
@@ -500,7 +528,12 @@ class Cleanup(commands.Cog):
|
||||
reason = (
|
||||
"{}({}) deleted {} messages "
|
||||
"sent by the bot in {}."
|
||||
"".format(author.name, author.id, len(to_delete), channel_name)
|
||||
"".format(
|
||||
author.name,
|
||||
author.id,
|
||||
humanize_number(len(to_delete), override_locale="en_US"),
|
||||
channel_name,
|
||||
)
|
||||
)
|
||||
log.info(reason)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user