diff --git a/exts/gacha/gacha_cmds.py b/exts/gacha/gacha_cmds.py index c88b5ea..f071637 100644 --- a/exts/gacha/gacha_cmds.py +++ b/exts/gacha/gacha_cmds.py @@ -50,9 +50,7 @@ async def gacha_roll(self, ctx: utils.THIASlashContext) -> None: if not ctx.author.has_role(config.player_role): raise utils.CustomCheckFailure("You do not have the Player role.") - player = await models.GachaPlayer.get_or_create( - ctx.guild.id, ctx.author.id, include={"items": True} - ) + player = await models.GachaPlayer.get_or_create(ctx.guild.id, ctx.author.id) if player.currency_amount < config.gacha.currency_cost: raise utils.CustomCheckFailure( @@ -72,9 +70,7 @@ async def gacha_roll(self, ctx: utils.THIASlashContext) -> None: "players": {"none": {"player_id": player.id}}, } - item_count = await models.GachaItem.prisma().count( - where=where, - ) + item_count = await models.GachaItem.prisma().count(where=where) if item_count == 0: raise utils.CustomCheckFailure("There are no items available to roll.") @@ -84,11 +80,16 @@ async def gacha_roll(self, ctx: utils.THIASlashContext) -> None: order={"id": "asc"}, ) + new_count = player.currency_amount - config.gacha.currency_cost + embed = item.embed() + embed.set_footer(f"{new_count} {config.names.currency_name(new_count)} left") + + await ctx.send(embed=embed) + async with self.bot.db.batch_() as batch: if item.amount != -1: - item.amount -= 1 batch.prismagachaitem.update( - data={"amount": item.amount}, where={"id": item.id} + data={"amount": {"decrement": 1}}, where={"id": item.id} ) batch.prismagachaplayer.update( @@ -102,12 +103,6 @@ async def gacha_roll(self, ctx: utils.THIASlashContext) -> None: } ) - new_count = player.currency_amount - config.gacha.currency_cost - embed = item.embed() - embed.set_footer(f"{new_count} {config.names.currency_name(new_count)} left") - - await ctx.send(embed=embed) - @gacha.subcommand( "pull", sub_cmd_description="Pulls for an item in the gacha. Alias of /gacha roll.",