Skip to content

Commit

Permalink
make the favorited countryball emoji customisable
Browse files Browse the repository at this point in the history
  • Loading branch information
imtherealF1 committed Jan 4, 2025
1 parent 80a57bf commit 672aea7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ballsdex/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tortoise import exceptions, fields, models, signals, timezone, validators
from tortoise.expressions import Q

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

if TYPE_CHECKING:
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 @@ -4,6 +4,7 @@

import discord

from ballsdex.settings import settings
from ballsdex.core.models import BallInstance
from ballsdex.core.utils import menus
from ballsdex.core.utils.paginator import Pages
Expand Down Expand Up @@ -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

0 comments on commit 672aea7

Please sign in to comment.