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

Added phrases customizability #386

Closed
Closed
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
Empty file modified ballsdex/core/image_generator/src/ArsenicaTrial-Extrabold.ttf
100755 → 100644
Empty file.
Empty file modified ballsdex/core/image_generator/src/Bobby Jones Soft.otf
100755 → 100644
Empty file.
Empty file modified ballsdex/core/image_generator/src/OpenSans-Bold.ttf
100755 → 100644
Empty file.
Empty file modified ballsdex/core/image_generator/src/OpenSans-Semibold.ttf
100755 → 100644
Empty file.
29 changes: 18 additions & 11 deletions ballsdex/packages/countryballs/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ async def on_submit(self, interaction: discord.Interaction["BallsDexBot"]):
config = await GuildConfig.create(guild_id=interaction.guild_id, spawn_channel=None)

if self.ball.catched:
message = f"{interaction.user.mention} {settings.caught_already_phrase}"
await interaction.followup.send(
f"{interaction.user.mention} I was caught already!",
ephemeral=config.silent,
message,
allowed_mentions=discord.AllowedMentions(users=player.can_be_mentioned),
ephemeral=config.silent,
)
return

Expand All @@ -87,25 +88,29 @@ async def on_submit(self, interaction: discord.Interaction["BallsDexBot"]):

special = ""
if ball.shiny:
special += f"✨ ***It's a shiny {settings.collectible_name}!*** ✨\n"
special += settings.shiny_phrase.format(collectible_name=settings.collectible_name)
if ball.specialcard and ball.specialcard.catch_phrase:
special += f"*{ball.specialcard.catch_phrase}*\n"
if has_caught_before:
special += (
f"This is a **new {settings.collectible_name}** "
"that has been added to your completion!"
special += settings.new_completion_phrase.format(
collectible_name=settings.collectible_name
)
message = (
f"{interaction.user.mention} "
f"{settings.you_caught_phrase.format(ball_name=self.ball.name)}"
f" `(#{ball.pk:0X}, {ball.attack_bonus:+}%/{ball.health_bonus:+}%)`\n\n"
f"{special}"
)
await interaction.followup.send(
f"{interaction.user.mention} You caught **{self.ball.name}!** "
f"`(#{ball.pk:0X}, {ball.attack_bonus:+}%/{ball.health_bonus:+}%)`\n\n"
f"{special}",
message,
allowed_mentions=discord.AllowedMentions(users=player.can_be_mentioned),
)
self.button.disabled = True
await interaction.followup.edit_message(self.ball.message.id, view=self.button.view)
else:
message = f"{interaction.user.mention} {settings.wrong_name_phrase}"
await interaction.followup.send(
f"{interaction.user.mention} Wrong name!",
message,
allowed_mentions=discord.AllowedMentions(users=player.can_be_mentioned),
ephemeral=config.silent,
)
Expand Down Expand Up @@ -174,7 +179,9 @@ def __init__(self, ball: "CountryBall"):

async def callback(self, interaction: discord.Interaction):
if self.ball.catched:
await interaction.response.send_message("I was caught already!", ephemeral=True)
MaxxMXSZ marked this conversation as resolved.
Show resolved Hide resolved
await interaction.response.send_message(
f"{settings.caught_already_phrase}", ephemeral=True
)
else:
await interaction.response.send_modal(CountryballNamePrompt(self.ball, self))

Expand Down
2 changes: 1 addition & 1 deletion ballsdex/packages/countryballs/countryball.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generate_random_name():
permissions = channel.permissions_for(channel.guild.me)
if permissions.attach_files and permissions.send_messages:
self.message = await channel.send(
f"A wild {settings.collectible_name} appeared!",
f"{settings.wild_phrase.format(collectible_name=settings.collectible_name)}",
view=CatchView(self),
file=discord.File(file_location, filename=file_name),
)
Expand Down
101 changes: 101 additions & 0 deletions ballsdex/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ class Settings:
List of roles that have full access to the /admin command
admin_role_ids: list[int]
List of roles that have partial access to the /admin command (only blacklist and guilds)
wild_phrase: str
The phrase used when a collectible spawns
wrong_name_phrase: str
The phrase used when a user enters the wrong name for that collectible
you_caught_phrase: str
The phrase used when a user catch a ball
new_completion_phrase: str = ""
The phrase used when a user caught a new collectible
caught_already_phrase: str
The phrase used when the collectible is caught already
shiny_phrase: str
The phrase used when the caught collectible is a shiny
"""

bot_token: str = ""
Expand All @@ -67,6 +79,12 @@ class Settings:
plural_collectible_name: str = "countryballs"
bot_name: str = "BallsDex"
players_group_cog_name: str = "balls"
wild_phrase: str = ""
wrong_name_phrase: str = ""
you_caught_phrase: str = ""
new_completion_phrase: str = ""
caught_already_phrase: str = ""
shiny_phrase: str = ""

max_favorites: int = 50
max_attack_bonus: int = 20
Expand Down Expand Up @@ -114,6 +132,18 @@ def read_settings(path: "Path"):
)
settings.bot_name = content["bot-name"]
settings.players_group_cog_name = content["players-group-cog-name"]
settings.wild_phrase = content.get("wild-phrase", "A wild {collectible_name}")
settings.wrong_name_phrase = content.get("wrong-name-phrase", "Wrong name!")
settings.you_caught_phrase = content.get("you-caught-phrase", "You caught {ball_name}!")
settings.new_completion_phrase = content.get(
"new-completion-phrase",
"This is a **new {collectible_name}** that has been added to your completion!",
)
settings.caught_already_phrase = content.get("caught-already-phrase", "I was caught already!")
settings.shiny_phrase = content.get(
"shiny-phrase",
"✨ ***It's a shiny {collectible_name}!*** ✨",
)

settings.about_description = content["about"]["description"]
settings.github_link = content["about"]["github-link"]
Expand Down Expand Up @@ -180,6 +210,29 @@ def write_default_settings(path: "Path"):
# this is /balls by default, but you can change it for /animals or /rocks for example
players-group-cog-name: balls

# override the phrase "A wild {collectible_name} appeared!
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
wild-phrase: A wild {collectible_name} appeared!

# override the phrase "Wrong name!"
wrong-name-phrase: Wrong name!

# override the phrase "You caught {ball_name}!"
# NOTE THAT you MUST include {ball_name} somewhere in the phrase
you-caught-phrase: You caught {ball_name}!

# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓ override the phrase ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
# "This is a **new {collectible_name}** that has been added to your completion!"
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
new-completion-phrase: This is a **new {collectible_name}** that has been added to your completion!

# override the phrase "I was caught already!"
caught-already-phrase: I was caught already!

# override the phrase "✨ ***It's a shiny {collectible_name}!*** ✨"
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
shiny-phrase: ✨ ***It's a shiny {collectible_name}!***

# maximum amount of favorites that are allowed
max-favorites: 50

Expand Down Expand Up @@ -237,6 +290,12 @@ def update_settings(path: "Path"):
add_max_attack = "max-attack-bonus" not in content
add_max_health = "max-health-bonus" not in content
add_plural_collectible = "plural-collectible-name" not in content
add_wild_phrase = "wild-phrase:" not in content
add_wrong_name_phrase = "wrong-name-phrase:" not in content
add_you_caught_phrase = "you-caught-phrase:" not in content
add_new_completion_phrase = "new-completion-phrase:" not in content
add_caught_already_phrase = "caught-already-phrase:" not in content
add_shiny_phrase = "shiny-phrase" not in content

for line in content.splitlines():
if line.startswith("owners:"):
Expand Down Expand Up @@ -278,11 +337,53 @@ def update_settings(path: "Path"):
# this cannot be smaller than 0, enter a positive number
max-health-bonus: 20
"""

if add_plural_collectible:
content += """
# WORK IN PROGRESS, DOES NOT FULLY WORK
# override the name "countryballs" in the bot
plural-collectible-name: countryballs
"""

if add_wild_phrase:
content += """
# Override the phrase 'A wild {collectible_name} appeared!'
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
wild-phrase: A wild {collectible_name} appeared!
"""

if add_wrong_name_phrase:
content += """
# Override the phrase 'Wrong name!'
wrong-name-phrase: Wrong name!
"""

if add_you_caught_phrase:
content += """
# Override the phrase 'You caught {ball_name}!'
# NOTE THAT you MUST include {ball_name} somewhere in the phrase
you-caught-phrase: You caught {ball_name}!
"""

if add_new_completion_phrase:
content += """
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓ override the phrase ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
# 'This is a **new {collectible_name}** that has been added to your completion!'
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
new-completion-phrase: This is a **new {collectible_name}** that has been added to your completion!
"""

if add_caught_already_phrase:
content += """
# Override the phrase 'I was caught already!'
caught-already-phrase: I was caught already!
"""

if add_shiny_phrase:
content += """
# override the phrase "✨ ***It's a shiny {collectible_name}!*** ✨"
# NOTE THAT you MUST include {collectible_name} somewhere in the phrase
shiny-phrase: ✨ ***It's a shiny {collectible_name}!***
"""

if any((add_owners, add_config_ref)):
Expand Down
30 changes: 30 additions & 0 deletions json-config-ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,36 @@
"description": "Name of the slash command managing the collectibles (list, info, completion...). Do not add a leading slash!",
"example": "balls"
},
"wild-phrase": {
"type": "string",
"description": "The phrase used when a collectible spawns",
"example": "A wild {collectible_name} appeared!"
},
"wrong-name-phrase": {
"type": "string",
"description": "The phrase used when a user enters the wrong name for that collectible",
"example": "Wrong name!"
},
"you-caught-phrase": {
"type": "string",
"description": "The phrase used when a user catch a collectible",
"example": "You caught {ball_name}!"
},
"new-comp-phrase": {
"type": "string",
"description": "The phrase used when a user caught a new collectible",
"example": "This is a **new {collectible_name}** that has been added to your completion!"
},
"caught-already-phrase": {
"type": "string",
"description": "The phrase used when a collectible is caught already",
"example": "I was caught already!"
},
"shiny-phrase": {
"type": "string",
"description": "The phrase used when the caught collectible is a shiny",
"example": "✨ ***It's a shiny {settings.collectible_name}!*** ✨"
},
"admin-command": {
"type": "object",
"description": "Manages access to the admin command",
Expand Down
Loading