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] make the favorited collectible emoji customisable #499

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion ballsdex/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from tortoise.expressions import Q

from ballsdex.core.image_generator.image_gen import draw_card
from ballsdex.settings import settings

if TYPE_CHECKING:
from tortoise.backends.base.client import BaseDBAsyncClient
Expand Down Expand Up @@ -281,7 +282,7 @@ def to_string(self, bot: discord.Client | None = None, is_trade: bool = False) -
if bot and self.pk in bot.locked_balls and not is_trade: # type: ignore
emotes += "🔒"
if self.favorite and not is_trade:
emotes += "❤️"
emotes += f"{settings.favorited_collectible_emoji}"
if emotes:
emotes += " "
if self.specialcard:
Expand Down
3 changes: 2 additions & 1 deletion ballsdex/packages/balls/countryballs_paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ballsdex.core.models import BallInstance
from ballsdex.core.utils import menus
from ballsdex.core.utils.paginator import Pages
from ballsdex.settings import settings

if TYPE_CHECKING:
from ballsdex.core.bot import BallsDexBot
Expand All @@ -32,7 +33,7 @@ def set_options(self, balls: List[BallInstance]):
options: List[discord.SelectOption] = []
for ball in balls:
emoji = self.bot.get_emoji(int(ball.countryball.emoji_id))
favorite = "❤️ " if ball.favorite else ""
favorite = f"{settings.favorited_collectible_emoji} " if ball.favorite else ""
special = ball.special_emoji(self.bot, True)
options.append(
discord.SelectOption(
Expand Down
2 changes: 1 addition & 1 deletion ballsdex/packages/trade/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def set_options(self, balls: List[BallInstance]):
if ball.is_tradeable is False:
continue
emoji = self.bot.get_emoji(int(ball.countryball.emoji_id))
favorite = "❤️ " if ball.favorite else ""
favorite = f"{settings.favorited_collectible_emoji} " if ball.favorite else ""
special = ball.special_emoji(self.bot, True)
options.append(
discord.SelectOption(
Expand Down
9 changes: 8 additions & 1 deletion ballsdex/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Settings:
Usually "BallsDex", can be replaced when possible
players_group_cog_name: str
Set the name of the base command of the "players" cog, /balls by default
max_favorites:
favorited_collectible_emoji: str
Set the emoji used to represent a favorited countryball, "❤️" by default.
max_favorites: int
Set the maximum amount of favorited countryballs a user can have, 50 by default.
max_attack_bonus:
Set the biggest/smallest attack bonus that a spawned countryball can have.
Expand Down Expand Up @@ -71,6 +73,7 @@ class Settings:
plural_collectible_name: str = "countryballs"
bot_name: str = "BallsDex"
players_group_cog_name: str = "balls"
favorited_collectible_emoji: str = "❤️"

max_favorites: int = 50
max_attack_bonus: int = 20
Expand Down Expand Up @@ -122,6 +125,7 @@ def read_settings(path: "Path"):
)
settings.bot_name = content["bot-name"]
settings.players_group_cog_name = content["players-group-cog-name"]
settings.favorited_collectible_emoji = content.get("favorited-collectible-emoji", "❤️")

settings.about_description = content["about"]["description"]
settings.github_link = content["about"]["github-link"]
Expand Down Expand Up @@ -202,6 +206,9 @@ 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

# emoji used to represent a favorited collectible
favorited-collectible-emoji: ❤️

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

Expand Down
5 changes: 5 additions & 0 deletions json-config-ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
"description": "Maximum number of favorite countryballs allowed per player",
"minimum": 0
},
"favorited-collectible-emoji": {
"type": "string",
"default": "❤️",
"description": "The emoji used to represent a favorited countryball"
},
"max-attack-bonus": {
"type": "integer",
"description": "The biggest/smallest attack bonus that a spawned countryball can have.",
Expand Down
Loading