fix(timers): Stop creating timer zombies.
Don't try to recreate a destroyed timer from an option setting.
This commit is contained in:
@@ -38,6 +38,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.channelid.name
|
_column = TimerData.Timer.channelid.name
|
||||||
|
_create_row = False
|
||||||
_allow_object = False
|
_allow_object = False
|
||||||
|
|
||||||
@TimerConfig.register_model_setting
|
@TimerConfig.register_model_setting
|
||||||
@@ -52,6 +53,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.notification_channelid.name
|
_column = TimerData.Timer.notification_channelid.name
|
||||||
|
_create_row = False
|
||||||
_allow_object = False
|
_allow_object = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -89,6 +91,7 @@ class TimerOptions(SettingGroup):
|
|||||||
)
|
)
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.inactivity_threshold.name
|
_column = TimerData.Timer.inactivity_threshold.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
_min = 0
|
_min = 0
|
||||||
_max = 64
|
_max = 64
|
||||||
@@ -122,6 +125,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.manager_roleid.name
|
_column = TimerData.Timer.manager_roleid.name
|
||||||
|
_create_row = False
|
||||||
_allow_object = False
|
_allow_object = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -149,6 +153,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.voice_alerts.name
|
_column = TimerData.Timer.voice_alerts.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
@TimerConfig.register_model_setting
|
@TimerConfig.register_model_setting
|
||||||
class BaseName(ModelData, StringSetting):
|
class BaseName(ModelData, StringSetting):
|
||||||
@@ -170,6 +175,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.pretty_name.name
|
_column = TimerData.Timer.pretty_name.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
@TimerConfig.register_model_setting
|
@TimerConfig.register_model_setting
|
||||||
class ChannelFormat(ModelData, StringSetting):
|
class ChannelFormat(ModelData, StringSetting):
|
||||||
@@ -189,6 +195,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.channel_name.name
|
_column = TimerData.Timer.channel_name.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def _parse_string(cls, parent_id, string, **kwargs):
|
async def _parse_string(cls, parent_id, string, **kwargs):
|
||||||
@@ -244,6 +251,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.focus_length.name
|
_column = TimerData.Timer.focus_length.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
_default_multiplier = 60
|
_default_multiplier = 60
|
||||||
allow_zero = False
|
allow_zero = False
|
||||||
@@ -284,6 +292,7 @@ class TimerOptions(SettingGroup):
|
|||||||
|
|
||||||
_model = TimerData.Timer
|
_model = TimerData.Timer
|
||||||
_column = TimerData.Timer.break_length.name
|
_column = TimerData.Timer.break_length.name
|
||||||
|
_create_row = False
|
||||||
|
|
||||||
_default_multiplier = 60
|
_default_multiplier = 60
|
||||||
allow_zero = False
|
allow_zero = False
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class Timer:
|
|||||||
'_voice_update_lock',
|
'_voice_update_lock',
|
||||||
'_run_task',
|
'_run_task',
|
||||||
'_loop_task',
|
'_loop_task',
|
||||||
|
'destroyed',
|
||||||
)
|
)
|
||||||
|
|
||||||
break_name = _p('timer|stage:break|name', "BREAK")
|
break_name = _p('timer|stage:break|name', "BREAK")
|
||||||
@@ -79,6 +80,8 @@ class Timer:
|
|||||||
# Main loop task. Should not be cancelled.
|
# Main loop task. Should not be cancelled.
|
||||||
self._loop_task = None
|
self._loop_task = None
|
||||||
|
|
||||||
|
self.destroyed = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return (
|
||||||
"<Timer "
|
"<Timer "
|
||||||
@@ -729,6 +732,7 @@ class Timer:
|
|||||||
self._run_task.cancel()
|
self._run_task.cancel()
|
||||||
channelid = self.data.channelid
|
channelid = self.data.channelid
|
||||||
await self.data.delete()
|
await self.data.delete()
|
||||||
|
self.destroyed = True
|
||||||
if self.last_status_message:
|
if self.last_status_message:
|
||||||
try:
|
try:
|
||||||
await self.last_status_message.delete()
|
await self.last_status_message.delete()
|
||||||
|
|||||||
@@ -37,6 +37,23 @@ class TimerOptionsUI(MessageUI):
|
|||||||
self.timer = timer
|
self.timer = timer
|
||||||
self.role = role
|
self.role = role
|
||||||
|
|
||||||
|
async def interaction_check(self, interaction: discord.Interaction):
|
||||||
|
if self.timer.destroyed:
|
||||||
|
t = self.bot.translator.t
|
||||||
|
error = t(_p(
|
||||||
|
'ui:timer_options|error:timer_destroyed',
|
||||||
|
"This timer no longer exists! Closing option menu."
|
||||||
|
))
|
||||||
|
embed = discord.Embed(
|
||||||
|
colour=discord.Colour.brand_red(),
|
||||||
|
description=error
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
|
await self.quit()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return await super().interaction_check(interaction)
|
||||||
|
|
||||||
@button(label="EDIT_PLACEHOLDER", style=ButtonStyle.blurple)
|
@button(label="EDIT_PLACEHOLDER", style=ButtonStyle.blurple)
|
||||||
async def edit_button(self, press: discord.Interaction, pressed: Button):
|
async def edit_button(self, press: discord.Interaction, pressed: Button):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user