Skip to content

Commit

Permalink
[RoleTools] Apparently I forgot to save this file
Browse files Browse the repository at this point in the history
- Explain how much currency is required when denied roles with a cost.
  • Loading branch information
TrustyJAID committed Dec 17, 2024
1 parent 4b78564 commit 91da5be
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions roletools/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ async def give_roles(
)
continue
if (cost := await self.config.role(role).cost()) and check_cost:
currency_name = await bank.get_currency_name(guild)
msg = _(
"You do not have enough {currency_name} to acquire "
"this role. You need {cost} {currency_name}."
).format(currency_name=currency_name, cost=cost)
if await bank.can_spend(member, cost):
try:
await bank.withdraw_credits(member, cost)
Expand All @@ -334,19 +339,16 @@ async def give_roles(
role,
member,
)
ret.append(
RoleChangeResponse(role, _("You do not have enough credits."), False)
)
ret.append(RoleChangeResponse(role, msg, False))
continue
else:
log.info(
"Could not assign %s to %s as they don't have enough credits.",
role,
member,
)
ret.append(
RoleChangeResponse(role, _("You do not have enough credits."), False)
)

ret.append(RoleChangeResponse(role, msg, False))
continue
if (inclusive := await self.config.role(role).inclusive_with()) and check_inclusive:
inclusive_roles = []
Expand Down

0 comments on commit 91da5be

Please sign in to comment.