fix (rooms): Use original cost when cancelling.
This commit is contained in:
@@ -73,7 +73,9 @@ async def cmd_rooms(ctx):
|
|||||||
{prefix}rooms book
|
{prefix}rooms book
|
||||||
{prefix}rooms cancel
|
{prefix}rooms cancel
|
||||||
Description:
|
Description:
|
||||||
View, book, or cancel your accountability sessions.
|
View your accountability profile with `{prefix}rooms`.
|
||||||
|
Use `{prefix}rooms book` to book an accountability session!
|
||||||
|
Use `{prefix}rooms cancel` to cancel a booked session.
|
||||||
"""
|
"""
|
||||||
lower = ctx.args.lower()
|
lower = ctx.args.lower()
|
||||||
splits = lower.split()
|
splits = lower.split()
|
||||||
@@ -154,12 +156,12 @@ async def cmd_rooms(ctx):
|
|||||||
]
|
]
|
||||||
if not to_cancel:
|
if not to_cancel:
|
||||||
return await ctx.error_reply("No valid bookings selected for cancellation.")
|
return await ctx.error_reply("No valid bookings selected for cancellation.")
|
||||||
cost = len(to_cancel) * ctx.guild_settings.accountability_price.value
|
elif any(row['start_at'] < utc_now() for row in to_cancel):
|
||||||
|
return await ctx.error_reply("You can't cancel a running session!")
|
||||||
|
|
||||||
slotids = [row['slotid'] for row in to_cancel]
|
slotids = [row['slotid'] for row in to_cancel]
|
||||||
async with room_lock:
|
async with room_lock:
|
||||||
# TODO: Use the return from this to calculate the cost!
|
deleted = accountability_members.delete_where(
|
||||||
accountability_members.delete_where(
|
|
||||||
userid=ctx.author.id,
|
userid=ctx.author.id,
|
||||||
slotid=slotids
|
slotid=slotids
|
||||||
)
|
)
|
||||||
@@ -182,7 +184,7 @@ async def cmd_rooms(ctx):
|
|||||||
await aguild.upcoming_slot.update_status()
|
await aguild.upcoming_slot.update_status()
|
||||||
break
|
break
|
||||||
|
|
||||||
ctx.alion.addCoins(cost)
|
ctx.alion.addCoins(sum(row[2] for row in deleted))
|
||||||
|
|
||||||
remaining = [row for row in joined_rows if row['slotid'] not in slotids]
|
remaining = [row for row in joined_rows if row['slotid'] not in slotids]
|
||||||
if not remaining:
|
if not remaining:
|
||||||
@@ -293,6 +295,8 @@ async def cmd_rooms(ctx):
|
|||||||
]
|
]
|
||||||
if not to_book:
|
if not to_book:
|
||||||
return await ctx.error_reply("No valid sessions selected.")
|
return await ctx.error_reply("No valid sessions selected.")
|
||||||
|
elif any(time < utc_now() for time in to_book):
|
||||||
|
return await ctx.error_reply("You can't book a running session!")
|
||||||
cost = len(to_book) * ctx.guild_settings.accountability_price.value
|
cost = len(to_book) * ctx.guild_settings.accountability_price.value
|
||||||
if cost > ctx.alion.coins:
|
if cost > ctx.alion.coins:
|
||||||
return await ctx.error_reply(
|
return await ctx.error_reply(
|
||||||
|
|||||||
Reference in New Issue
Block a user