Skip to content

Commit

Permalink
Fix: Couple Polishing Up Items for Trades (#201)
Browse files Browse the repository at this point in the history
* fix up a few things

* bump version
  • Loading branch information
zmattingly committed Jul 26, 2022
1 parent 6ccf7ac commit af60009
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions charts/agimus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: agimus
description: A helm chart for a discord bot that also runs a mysql db
type: application
version: v1.2.0
appVersion: v1.2.0
version: v1.2.1
appVersion: v1.2.1
31 changes: 25 additions & 6 deletions cogs/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ def __init__(self, cog, active_trade):
)

async def callback(self, interaction: discord.Interaction):
view = self.view
view.disable_all_items()
await interaction.response.edit_message(view=view)
await self.cog._accept_trade_callback(interaction, self.active_trade)

class DeclineButton(discord.ui.Button):
Expand Down Expand Up @@ -256,6 +253,15 @@ async def _accept_trade_callback(self, interaction, active_trade):
db_perform_badge_transfer(active_trade)
db_complete_trade(active_trade)

await interaction.response.edit_message(
embed=discord.Embed(
title="Trade Successful!",
color=discord.Color.dark_purple()
),
view=None,
attachments=[]
)

# Send Message to Channel
requestor = await self.bot.fetch_user(active_trade["requestor_id"])
requestee = await self.bot.fetch_user(active_trade["requestee_id"])
Expand Down Expand Up @@ -286,6 +292,9 @@ async def _accept_trade_callback(self, interaction, active_trade):
user = get_user(requestor.id)
if user["receive_notifications"]:
try:
success_embed.set_footer(
text="Note: You can use /toggle_notifications to enable or disable these messages."
)
await requestor.send(embed=success_embed)
except discord.Forbidden as e:
logger.info(f"Unable to send trade cancelation message to {requestor.display_name}, they have their DMs closed.")
Expand Down Expand Up @@ -326,7 +335,9 @@ async def _cancel_invalid_related_trades(self, active_trade):
name=f"Requested from {requestee.display_name}",
value=requested_badge_names
)
requestee_embed.set_footer(text="Thank you and have a nice day!")
requestee_embed.set_footer(
text="Note: You can use /toggle_notifications to enable or disable these messages."
)
await requestee.send(embed=requestee_embed)
except discord.Forbidden as e:
logger.info(f"Unable to send trade cancelation message to {requestee.display_name}, they have their DMs closed.")
Expand All @@ -349,7 +360,9 @@ async def _cancel_invalid_related_trades(self, active_trade):
name=f"Requested from {requestee.display_name}",
value=requested_badge_names
)
requestor_embed.set_footer(text="Thank you and have a nice day!")
requestor_embed.set_footer(
text="Note: You can use /toggle_notifications to enable or disable these messages."
)
await requestor.send(embed=requestor_embed)
except discord.Forbidden as e:
logger.info(f"Unable to send trade cancelation message to {requestor.display_name}, they have their DMs closed.")
Expand Down Expand Up @@ -450,7 +463,7 @@ async def start(self, ctx:discord.ApplicationContext, requestee:discord.User):
active_trade_requestee = await self.bot.fetch_user(active_trade['requestee_id'])
already_active_embed = discord.Embed(
title="You already have an active trade!",
description=f"You have a outgoing trade open with {active_trade_requestee.mention}.\n\nUse `/trade cancel` cancel the current trade if desired!\n\nThis must be resolved before you can open another request.",
description=f"You have a outgoing trade open with {active_trade_requestee.mention}.\n\nUse `/trade status` to cancel the current trade if desired!\n\nThis must be resolved before you can open another request.",
color=discord.Color.red()
)
already_active_embed.set_footer(text="You may want to check on this trade to see if they have had a chance to review your request!")
Expand Down Expand Up @@ -561,6 +574,9 @@ async def _cancel_trade_callback(self, interaction, active_trade):
name=f"Requested from {requestee.display_name}",
value=requested_badge_names
)
notification_embed.set_footer(
text="Note: You can use /toggle_notifications to enable or disable these messages."
)

await requestee.send(embed=notification_embed)
except discord.Forbidden as e:
Expand Down Expand Up @@ -631,6 +647,9 @@ async def _send_trade_callback(self, interaction, active_trade):
name=f"Requested from {requestee.display_name}",
value=requested_badge_names
)
requestee_embed.set_footer(
text="Note: You can use /toggle_notifications to enable or disable these messages."
)
await requestee.send(embed=requestee_embed)
except discord.Forbidden as e:
logger.info(f"Unable to send trade cancelation message to {requestor.display_name}, they have their DMs closed.")
Expand Down
2 changes: 1 addition & 1 deletion data/help/badges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You may have up to three incoming trades at a time.
**Outgoing Trades**
`/trade start <user>` - Must be done initially! Create a 'pending' trade with a user which you can modify to add offered/requested badges

`/trade propose <offer/request> <badge name>` - Add your offer and requested badges to the pending trade.
`/trade propose <offer/request> <badge name>` - Add your offered and requested badges to the pending trade.

`/trade status` - View the current details of your Active or Pending trade. Has buttons to Cancel and if currently pending, Send the proposed trade.

Expand Down

0 comments on commit af60009

Please sign in to comment.