Skip to content

Commit

Permalink
Fixing critical error with shift management
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeyUsersREC committed Jan 21, 2024
1 parent 4eb767f commit 2335020
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5988,7 +5988,25 @@ def check_buttons(self, option: typing.Literal['on', 'break', 'off']):
item.disabled = False

async def interaction_check(self, interaction: Interaction, /) -> bool:

if interaction.user.id == self.user_id:
# Refresh current data to ensure state has not changed
current_shift = await self.bot.shift_management.get_current_shift(interaction.user, interaction.guild.id)
self.shift = current_shift
if self.shift:
self.contained_document = await self.bot.shift_management.fetch_shift(self.shift['_id'])
else:
self.contained_document = None
if self.contained_document:
if self.contained_document.breaks:
if self.contained_document.breaks[-1].end_epoch == 0:
self.state = 'break'
else:
self.state = 'on'
else:
self.state = 'on'
else:
self.state = 'off'
return True
else:
await interaction.response.send_message(embed=discord.Embed(
Expand Down Expand Up @@ -6076,6 +6094,7 @@ async def on_duty_button(self, interaction: discord.Interaction, _: discord.Butt
self.shift["Breaks"][-1]['EndEpoch'] = datetime.datetime.now(tz=pytz.UTC).timestamp()
self.shift['_id'] = self.contained_document.id
await self.bot.shift_management.shifts.update_by_id(self.shift)
await asyncio.sleep(1)
self.contained_document = await self.bot.shift_management.fetch_shift(self.contained_document.id)
await self.cycle_ui('on', interaction.message)
self.bot.dispatch('break_end', self.contained_document.id)
Expand Down

0 comments on commit 2335020

Please sign in to comment.