From b83b347d6aa15010a9c4dc3917e5887218a4a47c Mon Sep 17 00:00:00 2001 From: Rene Arumetsa Date: Tue, 19 May 2026 18:37:42 +0300 Subject: [PATCH] Fix shop interation --- commands/economy_extra_commands.py | 3 +- commands/economy_income_commands.py | 45 ++++++++++++++++------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/commands/economy_extra_commands.py b/commands/economy_extra_commands.py index 538eb92..af65f24 100644 --- a/commands/economy_extra_commands.py +++ b/commands/economy_extra_commands.py @@ -822,8 +822,9 @@ def register_economy_extra_commands( async def callback(interaction: discord.Interaction): self._tier = tier self._update_buttons() + await interaction.response.defer(edit_message=True) self._user_data = await economy.get_user(interaction.user.id) - await interaction.response.edit_message( + await interaction.edit_original_response( embed=_shop_embed(self._tier, self._user_data), view=self, ) diff --git a/commands/economy_income_commands.py b/commands/economy_income_commands.py index b4789e2..c6b1088 100644 --- a/commands/economy_income_commands.py +++ b/commands/economy_income_commands.py @@ -22,12 +22,13 @@ def register_economy_income_commands( ) -> None: @tree.command(name="daily", description=S.CMD["daily"]) async def cmd_daily(interaction: discord.Interaction): + await interaction.response.defer() res = await economy.do_daily(interaction.user.id) if not res["ok"]: if res["reason"] == "banned": - await interaction.response.send_message(S.MSG_BANNED, ephemeral=True) + await interaction.followup.send(S.MSG_BANNED, ephemeral=True) elif res["reason"] == "cooldown": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["daily"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) @@ -51,7 +52,7 @@ def register_economy_income_commands( lines.append(S.DAILY_UI["footer"].format(streak_str=streak_str, balance=coin(res["balance"]))) embed = discord.Embed(title=S.TITLE["daily"], description="\n".join(lines), color=0xF4C430) - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) asyncio.create_task(maybe_remind(interaction.user.id, "daily")) asyncio.create_task(award_exp(interaction, economy.EXP_REWARDS["daily"])) @@ -59,17 +60,18 @@ def register_economy_income_commands( async def cmd_work(interaction: discord.Interaction): if await check_cmd_rate(interaction): return + await interaction.response.defer() res = await economy.do_work(interaction.user.id) if not res["ok"]: if res["reason"] == "banned": - await interaction.response.send_message(S.MSG_BANNED, ephemeral=True) + await interaction.followup.send(S.MSG_BANNED, ephemeral=True) elif res["reason"] == "cooldown": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["work"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) elif res["reason"] == "jailed": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["jailed"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) @@ -84,7 +86,7 @@ def register_economy_income_commands( desc += S.WORK_UI["laud"] desc += S.WORK_UI["balance"].format(balance=coin(res["balance"])) embed = discord.Embed(title=S.TITLE["work"], description=desc, color=0x57F287) - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) asyncio.create_task(maybe_remind(interaction.user.id, "work")) asyncio.create_task(award_exp(interaction, economy.EXP_REWARDS["work"])) @@ -92,12 +94,13 @@ def register_economy_income_commands( async def cmd_beg(interaction: discord.Interaction): if await check_cmd_rate(interaction): return + await interaction.response.defer() res = await economy.do_beg(interaction.user.id) if not res["ok"]: if res["reason"] == "banned": - await interaction.response.send_message(S.MSG_BANNED, ephemeral=True) + await interaction.followup.send(S.MSG_BANNED, ephemeral=True) elif res["reason"] == "cooldown": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["beg"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) @@ -114,7 +117,7 @@ def register_economy_income_commands( beg_lines.append(S.BEG_UI["klaviatuur"]) beg_lines.append(S.BEG_UI["balance"].format(balance=coin(res["balance"]))) embed = discord.Embed(title=title, description="\n".join(beg_lines), color=color) - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) asyncio.create_task(maybe_remind(interaction.user.id, "beg")) asyncio.create_task(award_exp(interaction, economy.EXP_REWARDS["beg"])) @@ -122,17 +125,18 @@ def register_economy_income_commands( async def cmd_crime(interaction: discord.Interaction): if await check_cmd_rate(interaction): return + await interaction.response.defer() res = await economy.do_crime(interaction.user.id) if not res["ok"]: if res["reason"] == "banned": - await interaction.response.send_message(S.MSG_BANNED, ephemeral=True) + await interaction.followup.send(S.MSG_BANNED, ephemeral=True) elif res["reason"] == "cooldown": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["crime"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) elif res["reason"] == "jailed": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["jailed"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) @@ -161,7 +165,7 @@ def register_economy_income_commands( + S.CRIME_UI["balance"].format(balance=coin(res["balance"])), color=0xED4245, ) - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) asyncio.create_task(maybe_remind(interaction.user.id, "crime")) if res["success"]: asyncio.create_task(award_exp(interaction, economy.EXP_REWARDS["crime_win"])) @@ -180,27 +184,28 @@ def register_economy_income_commands( await interaction.response.send_message(S.ERR["rob_house_blocked"], ephemeral=True) return + await interaction.response.defer() res = await economy.do_rob(interaction.user.id, sihtmärk.id) if not res["ok"]: if res["reason"] == "banned": - await interaction.response.send_message(S.MSG_BANNED, ephemeral=True) + await interaction.followup.send(S.MSG_BANNED, ephemeral=True) elif res["reason"] == "cooldown": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["rob"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) elif res["reason"] == "jailed": - await interaction.response.send_message( + await interaction.followup.send( S.CD_MSG["jailed"].format(ts=cd_ts(res["remaining"])), ephemeral=True, ) elif res["reason"] == "broke": - await interaction.response.send_message( + await interaction.followup.send( S.ERR["rob_too_poor"].format(name=sihtmärk.display_name), ephemeral=True, ) elif res["reason"] == "target_jailed": - await interaction.response.send_message( + await interaction.followup.send( S.ERR["rob_target_jailed"].format(name=sihtmärk.display_name), ephemeral=True, ) @@ -242,7 +247,7 @@ def register_economy_income_commands( ), color=0xED4245, ) - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) asyncio.create_task(maybe_remind(interaction.user.id, "rob")) if res["success"]: asyncio.create_task(award_exp(interaction, economy.EXP_REWARDS["rob_win"]))