Skip to content

Commit

Permalink
Merge branch 'master' into feat/bulk-add-sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
laggron42 committed Dec 10, 2024
2 parents d3796dc + 1f9e074 commit e7745cb
Show file tree
Hide file tree
Showing 6 changed files with 636 additions and 663 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Auguste Charpentier
Copyright (c) 2021-2024 Auguste Charpentier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 19 additions & 14 deletions ballsdex/core/admin/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,36 @@ class BallResource(Model):
name="emoji_id",
label="Emoji",
display=Emoji(),
input_=inputs.Input(
help_text="Emoji ID of this ball. Application emojis not supported. "
"Send \\:emoji-name: on Discord to obtain the ID."
),
),
Field(
name="wild_card",
label="Wild card",
display=displays.Image(width="40"),
input_=inputs.Image(upload=upload, null=True),
input_=inputs.Image(
upload=upload,
null=True,
help_text="The file uploaded when this ball spawns. You certify that you have "
"the permission from the copyright holder to use this file.",
),
),
Field(
name="collection_card",
label="Collection card (16:9 ratio)",
display=displays.Image(width="40"),
input_=inputs.Image(upload=upload, null=True),
),
Field(
name="credits",
label="Image credits",
),
Field(
name="capacity_name",
label="Capacity name",
),
Field(
name="capacity_description",
label="Capacity description",
input_=inputs.Image(
upload=upload,
null=True,
help_text="The image used to generate the collection card. You certify that "
"you have the permission from the copyright holder to use this file.",
),
),
"credits",
"capacity_name",
"capacity_description",
]

async def get_actions(self, request: Request) -> List[Action]:
Expand Down
17 changes: 12 additions & 5 deletions ballsdex/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,25 @@ async def reloadtree(self, ctx: commands.Context):
await self.bot.tree.sync()
await ctx.send("Application commands tree reloaded.")

async def reload_package(self, package: str, *, with_prefix=False):
try:
try:
await self.bot.reload_extension(package)
except commands.ExtensionNotLoaded:
await self.bot.load_extension(package)
except commands.ExtensionNotFound:
if not with_prefix:
return await self.reload_package("ballsdex.packages." + package, with_prefix=True)
raise

@commands.command()
@commands.is_owner()
async def reload(self, ctx: commands.Context, package: str):
"""
Reload an extension
"""
package = "ballsdex.packages." + package
try:
try:
await self.bot.reload_extension(package)
except commands.ExtensionNotLoaded:
await self.bot.load_extension(package)
await self.reload_package(package)
except commands.ExtensionNotFound:
await ctx.send("Extension not found.")
except Exception:
Expand Down
27 changes: 20 additions & 7 deletions ballsdex/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ class Ball(models.Model):
regime_id: int
economy_id: int

country = fields.CharField(max_length=48, unique=True)
short_name = fields.CharField(max_length=12, null=True, default=None)
country = fields.CharField(max_length=48, unique=True, description="Name of this countryball")
short_name = fields.CharField(
max_length=12,
null=True,
default=None,
description="Alternative shorter name to be used in card design, "
"12 characters max, optional",
)
catch_names = fields.TextField(
null=True,
default=None,
Expand All @@ -151,9 +157,16 @@ class Ball(models.Model):
)
health = fields.IntField(description="Ball health stat")
attack = fields.IntField(description="Ball attack stat")
rarity = fields.FloatField(description="Rarity of this ball")
enabled = fields.BooleanField(default=True)
tradeable = fields.BooleanField(default=True)
rarity = fields.FloatField(
description="Rarity of this ball. "
"Higher number means more likely to spawn, 0 is unspawnable."
)
enabled = fields.BooleanField(
default=True, description="Disabled balls will never spawn or show up in completion."
)
tradeable = fields.BooleanField(
default=True, description="Controls whether this ball can be traded or donated."
)
emoji_id = fields.BigIntField(
description="Emoji ID for this ball", validators=[DiscordSnowflakeValidator()]
)
Expand All @@ -165,10 +178,10 @@ class Ball(models.Model):
)
credits = fields.CharField(max_length=64, description="Author of the collection artwork")
capacity_name = fields.CharField(
max_length=64, description="Name of the countryball's capacity"
max_length=64, description="Name of the countryball's ability"
)
capacity_description = fields.CharField(
max_length=256, description="Description of the countryball's capacity"
max_length=256, description="Description of the countryball's ability"
)
capacity_logic = fields.JSONField(description="Effect of this capacity", default={})
created_at = fields.DatetimeField(auto_now_add=True, null=True)
Expand Down
Loading

0 comments on commit e7745cb

Please sign in to comment.