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

[settings] Pluralization Support, with {settings.plural_collectible_name} #378

Merged
merged 14 commits into from
Sep 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ballsdex/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def reset_settings(path: Path):

def print_welcome():
print("[green]{0:-^50}[/green]".format(f" {settings.bot_name} bot "))
print("[green]{0: ^50}[/green]".format(f" Collect {settings.collectible_name}s "))
print("[green]{0: ^50}[/green]".format(f" Collect {settings.plural_collectible_name} "))
print("[blue]{0:^50}[/blue]".format("Discord bot made by El Laggron"))
print("")
print(" [red]{0:<20}[/red] [yellow]{1:>10}[/yellow]".format("Bot version:", bot_version))
Expand Down
29 changes: 15 additions & 14 deletions ballsdex/packages/admin/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ async def cooldown(
informations.append("The manager is currently on cooldown.")
if delta < 600:
informations.append(
f"The manager is less than 10 minutes old, {settings.collectible_name}s "
f"The manager is less than 10 minutes old, {settings.plural_collectible_name} "
"cannot spawn at the moment."
)
if informations:
Expand Down Expand Up @@ -464,7 +464,7 @@ async def update_message_loop():
task.cancel()
await interaction.followup.edit_message(
"@original", # type: ignore
content=f"Successfully spawned {spawned} {settings.collectible_name}s "
content=f"Successfully spawned {spawned} {settings.plural_collectible_name} "
f"in {channel.mention}!",
)
finally:
Expand Down Expand Up @@ -1139,11 +1139,11 @@ async def balls_reset(
await interaction.response.defer(ephemeral=True, thinking=True)

if not percentage:
text = f"Are you sure you want to delete {user}'s {settings.collectible_name}s?"
text = f"Are you sure you want to delete {user}'s {settings.plural_collectible_name}?"
else:
text = (
f"Are you sure you want to delete {percentage}% of "
f"{user}'s {settings.collectible_name}s?"
f"{user}'s {settings.plural_collectible_name}?"
)
view = ConfirmChoiceView(interaction)
await interaction.followup.send(
Expand All @@ -1163,11 +1163,12 @@ async def balls_reset(
else:
count = await BallInstance.filter(player=player).delete()
await interaction.followup.send(
f"{count} {settings.collectible_name}s from {user} have been deleted.", ephemeral=True
f"{count} {settings.plural_collectible_name} from {user} have been deleted.",
ephemeral=True,
)
await log_action(
f"{interaction.user} deleted {percentage or 100}% of "
f"{player}'s {settings.collectible_name}s.",
f"{player}'s {settings.plural_collectible_name}.",
self.bot,
)

Expand Down Expand Up @@ -1642,11 +1643,11 @@ async def guild(
embed.add_field(name="Spawn enabled:", value=spawn_enabled)
embed.add_field(name="Created at:", value=format_dt(guild.created_at, style="F"))
embed.add_field(
name=f"{settings.collectible_name.title()}s caught ({days} days):",
name=f"{settings.plural_collectible_name.title()} caught ({days} days):",
value=len(total_server_balls),
)
embed.add_field(
name="Amount of users who caught\n" f"{settings.collectible_name}s ({days} days):",
name=f"Amount of users who caught\n{settings.plural_collectible_name} ({days} days):",
value=len(set([x.player.discord_id for x in total_server_balls])),
)

Expand Down Expand Up @@ -1689,27 +1690,27 @@ async def user(
color=discord.Color.blurple(),
)
embed.add_field(
name=f"{settings.collectible_name.title()}s caught ({days} days):",
name=f"{settings.plural_collectible_name.title()} caught ({days} days):",
value=len(total_user_balls),
)
embed.add_field(
name=f"Unique {settings.collectible_name}s caught ({days} days):",
name=f"Unique {settings.plural_collectible_name} caught ({days} days):",
value=len(set(total_user_balls)),
)
embed.add_field(
name=f"Total servers with {settings.collectible_name}s caught ({days} days):",
name=f"Total servers with {settings.plural_collectible_name} caught ({days} days):",
value=len(set([x.server_id for x in total_user_balls])),
)
embed.add_field(
name=f"Total {settings.collectible_name}s caught:",
name=f"Total {settings.plural_collectible_name} caught:",
value=await BallInstance.filter(player__discord_id=user.id).count(),
)
embed.add_field(
name=f"Total unique {settings.collectible_name}s caught:",
name=f"Total unique {settings.plural_collectible_name} caught:",
value=len(set([x.countryball for x in total_user_balls])),
)
embed.add_field(
name=f"Total servers with {settings.collectible_name}s caught:",
name=f"Total servers with {settings.plural_collectible_name} caught:",
value=len(set([x.server_id for x in total_user_balls])),
)
embed.set_thumbnail(url=user.display_avatar) # type: ignore
Expand Down
38 changes: 24 additions & 14 deletions ballsdex/packages/balls/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ async def list(
except DoesNotExist:
if user_obj == interaction.user:
await interaction.followup.send(
f"You don't have any {settings.collectible_name}s yet."
f"You don't have any {settings.plural_collectible_name} yet."
)
else:
await interaction.followup.send(
f"{user_obj.name} doesn't have any {settings.collectible_name}s yet."
f"{user_obj.name} doesn't have any {settings.plural_collectible_name} yet."
)
return
if user is not None:
Expand Down Expand Up @@ -212,12 +212,12 @@ async def list(
if user_obj == interaction.user:
await interaction.followup.send(
f"You don't have any {special_txt}{ball_txt} "
f"{settings.collectible_name}s yet."
f"{settings.plural_collectible_name} yet."
)
else:
await interaction.followup.send(
f"{user_obj.name} doesn't have any "
f"{special_txt}{ball_txt} {settings.collectible_name}s yet."
f"{special_txt}{ball_txt} {settings.plural_collectible_name} yet."
)
return
if reverse:
Expand All @@ -228,7 +228,7 @@ async def list(
await paginator.start()
else:
await paginator.start(
content=f"Viewing {user_obj.name}'s {settings.collectible_name}s"
content=f"Viewing {user_obj.name}'s {settings.plural_collectible_name}"
)

@app_commands.command()
Expand Down Expand Up @@ -260,7 +260,7 @@ async def completion(
except DoesNotExist:
await interaction.response.send_message(
f"{user_obj.name} doesn't have any "
f"{extra_text}{settings.collectible_name}s yet."
f"{extra_text}{settings.plural_collectible_name} yet."
)
return
if await inventory_privacy(self.bot, interaction, player, user_obj) is False:
Expand All @@ -280,7 +280,7 @@ async def completion(
}
if not bot_countryballs:
await interaction.response.send_message(
f"There are no {extra_text}{settings.collectible_name}s"
f"There are no {extra_text}{settings.plural_collectible_name}"
" registered on this bot yet.",
ephemeral=True,
)
Expand Down Expand Up @@ -329,18 +329,18 @@ def fill_fields(title: str, emoji_ids: set[int]):
if owned_countryballs:
# Getting the list of emoji IDs from the IDs of the owned countryballs
fill_fields(
f"Owned {settings.collectible_name}s",
f"Owned {settings.plural_collectible_name}",
set(bot_countryballs[x] for x in owned_countryballs),
)
else:
entries.append((f"__**Owned {settings.collectible_name}s**__", "Nothing yet."))

if missing := set(y for x, y in bot_countryballs.items() if x not in owned_countryballs):
fill_fields(f"Missing {settings.collectible_name}s", missing)
fill_fields(f"Missing {settings.plural_collectible_name}", missing)
else:
entries.append(
(
f"__**:tada: No missing {settings.collectible_name}s, "
f"__**:tada: No missing {settings.plural_collectible_name}, "
"congratulations! :tada:**__",
"\u200B",
)
Expand Down Expand Up @@ -405,7 +405,7 @@ async def last(self, interaction: discord.Interaction, user: discord.User | None
except DoesNotExist:
msg = f"{'You do' if user is None else f'{user_obj.display_name} does'}"
await interaction.followup.send(
f"{msg} not have any {settings.collectible_name}s yet.",
f"{msg} not have any {settings.plural_collectible_name} yet.",
ephemeral=True,
)
return
Expand All @@ -418,7 +418,7 @@ async def last(self, interaction: discord.Interaction, user: discord.User | None
if not countryball:
msg = f"{'You do' if user is None else f'{user_obj.display_name} does'}"
await interaction.followup.send(
f"{msg} not have any {settings.collectible_name}s yet.",
f"{msg} not have any {settings.plural_collectible_name} yet.",
ephemeral=True,
)
return
Expand Down Expand Up @@ -455,12 +455,22 @@ async def favorite(
if not countryball:
return

if settings.max_favorites == 0:
await interaction.response.send_message(
f"You cannot set favorite {settings.plural_collectible_name} in this bot."
)
return

if not countryball.favorite:
player = await Player.get(discord_id=interaction.user.id).prefetch_related("balls")
grammar = (
f"{settings.collectible_name}"
if settings.max_favorites == 1
else f"{settings.plural_collectible_name}"
)
if await player.balls.filter(favorite=True).count() >= settings.max_favorites:
await interaction.response.send_message(
f"You cannot set more than {settings.max_favorites} "
f"favorite {settings.collectible_name}s.",
f"You cannot set more than {settings.max_favorites} favorite {grammar}.",
ephemeral=True,
)
return
Expand Down
10 changes: 5 additions & 5 deletions ballsdex/packages/config/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
description=f"To enable {settings.bot_name} in your server, you must "
f"read and accept the [Terms of Service]({settings.terms_of_service}).\n\n"
"As a summary, these are the rules of the bot:\n"
f"- No farming (spamming or creating servers for {settings.collectible_name}s)\n"
f"- Selling or exchanging {settings.collectible_name}s "
f"- No farming (spamming or creating servers for {settings.plural_collectible_name})\n"
f"- Selling or exchanging {settings.plural_collectible_name} "
"against money or other goods is forbidden\n"
"- Do not attempt to abuse the bot's internals\n"
"**Not respecting these rules will lead to a blacklist**",
Expand Down Expand Up @@ -89,8 +89,8 @@ async def disable(self, interaction: discord.Interaction):
self.bot.dispatch("ballsdex_settings_change", guild, enabled=False)
await interaction.response.send_message(
f"{settings.bot_name} is now disabled in this server. Commands will still be "
f"available, but the spawn of new {settings.collectible_name}s is suspended.\n"
"To re-enable the spawn, use the same command."
f"available, but the spawn of new {settings.plural_collectible_name}"
"is suspended.\nTo re-enable the spawn, use the same command."
)
else:
config.enabled = True # type: ignore
Expand All @@ -100,7 +100,7 @@ async def disable(self, interaction: discord.Interaction):
if channel:
await interaction.response.send_message(
f"{settings.bot_name} is now enabled in this server, "
f"{settings.collectible_name}s will start spawning "
f"{settings.plural_collectible_name} will start spawning "
f"soon in {channel.mention}."
)
else:
Expand Down
4 changes: 2 additions & 2 deletions ballsdex/packages/info/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ async def about(self, interaction: discord.Interaction):
f"{' '.join(str(x) for x in balls)}\n"
f"{settings.about_description}\n"
f"*Running version **[{ballsdex_version}]({settings.github_link}/releases)***\n\n"
f"**{balls_count:,}** {settings.collectible_name}s to collect\n"
f"**{balls_count:,}** {settings.plural_collectible_name} to collect\n"
f"**{players_count:,}** players that caught "
f"**{balls_instances_count:,}** {settings.collectible_name}s\n"
f"**{balls_instances_count:,}** {settings.plural_collectible_name}\n"
f"**{len(self.bot.guilds):,}** servers playing\n\n"
f"{dex_credits}\n\n"
"Consider supporting El Laggron on "
Expand Down
4 changes: 2 additions & 2 deletions ballsdex/packages/players/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ async def donation_policy(
player.donation_policy = DonationPolicy(policy.value)
if policy.value == DonationPolicy.ALWAYS_ACCEPT:
await interaction.response.send_message(
f"Setting updated, you will now receive all donated {settings.collectible_name}s "
"immediately."
"Setting updated, you will now receive all donated "
f"{settings.plural_collectible_name} immediately."
)
elif policy.value == DonationPolicy.REQUEST_APPROVAL:
await interaction.response.send_message(
Expand Down
12 changes: 6 additions & 6 deletions ballsdex/packages/trade/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async def bulk_add(
balls = await BallInstance.filter(**filters).prefetch_related("ball", "player")
if not balls:
await interaction.followup.send(
f"No {settings.collectible_name}s found.", ephemeral=True
f"No {settings.plural_collectible_name} found.", ephemeral=True
)
return

Expand All @@ -268,18 +268,18 @@ async def bulk_add(

if len(balls) < 25:
await interaction.followup.send(
f"You have less than 25 {settings.collectible_name}s, "
f"You have less than 25 {settings.plural_collectible_name}, "
"you can use the add command instead.",
ephemeral=True,
)
return

view = BulkAddView(interaction, balls, self) # type: ignore
await view.start(
content=f"Select the {settings.collectible_name}s you want to add to your proposal,"
" note that the display will wipe on pagination however "
f"the selected {settings.collectible_name}s will remain.\n"
f"{settings.collectible_name.title()}s were rounded down to closest 25 for "
content=f"Select the {settings.plural_collectible_name} you want to add "
"to your proposal, note that the display will wipe on pagination however "
f"the selected {settings.plural_collectible_name} will remain.\n"
f"{settings.plural_collectible_name.title()} were rounded down to closest 25 for "
"display purposes, final page may be missing entries."
)

Expand Down
Loading
Loading