Merge branch 'release' into pillow
This commit is contained in:
@@ -73,7 +73,7 @@ class TimerCog(LionCog):
|
||||
launched=sum(1 for timer in timers if timer._run_task and not timer._run_task.done()),
|
||||
looping=sum(1 for timer in timers if timer._loop_task and not timer._loop_task.done()),
|
||||
locked=sum(1 for timer in timers if timer._lock.locked()),
|
||||
voice_locked=sum(1 for timer in timers if timer._voice_update_lock.locked()),
|
||||
voice_locked=sum(1 for timer in timers if timer.voice_lock.locked()),
|
||||
)
|
||||
if not self.ready:
|
||||
level = StatusLevel.STARTING
|
||||
@@ -345,7 +345,7 @@ class TimerCog(LionCog):
|
||||
|
||||
@LionCog.listener('on_guildset_pomodoro_channel')
|
||||
@log_wrap(action='Update Pomodoro Channels')
|
||||
async def _update_pomodoro_channels(self, guildid: int, data: Optional[int]):
|
||||
async def _update_pomodoro_channels(self, guildid: int, setting: TimerSettings.PomodoroChannel):
|
||||
"""
|
||||
Request a send_status for all guild timers which need to move channel.
|
||||
"""
|
||||
|
||||
@@ -57,7 +57,7 @@ class TimerOptions(SettingGroup):
|
||||
_allow_object = False
|
||||
|
||||
@classmethod
|
||||
async def _check_value(cls, parent_id: int, value: Optional[discord.abc.GuildChannel], **kwargs):
|
||||
async def _check_value(cls, parent_id: int, value, **kwargs):
|
||||
if value is not None:
|
||||
# TODO: Check we either have or can create a webhook
|
||||
# TODO: Check we can send messages, embeds, and files
|
||||
|
||||
@@ -136,6 +136,10 @@ class Timer:
|
||||
channel = self.channel
|
||||
return channel
|
||||
|
||||
@property
|
||||
def voice_lock(self):
|
||||
return self.lguild.voice_lock
|
||||
|
||||
async def get_notification_webhook(self) -> Optional[discord.Webhook]:
|
||||
channel = self.notification_channel
|
||||
if channel:
|
||||
@@ -474,14 +478,13 @@ class Timer:
|
||||
async with self.lguild.voice_lock:
|
||||
try:
|
||||
if self.guild.voice_client:
|
||||
print("Disconnecting")
|
||||
await self.guild.voice_client.disconnect(force=True)
|
||||
print("Disconnected")
|
||||
alert_file = focus_alert_path if stage.focused else break_alert_path
|
||||
try:
|
||||
print("Connecting")
|
||||
voice_client = await self.channel.connect(timeout=60, reconnect=False)
|
||||
print("Connected")
|
||||
voice_client = await asyncio.wait_for(
|
||||
self.channel.connect(timeout=30, reconnect=False),
|
||||
timeout=60
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(f"Timed out while connecting to voice channel in timer {self!r}")
|
||||
return
|
||||
@@ -508,13 +511,18 @@ class Timer:
|
||||
_, pending = await asyncio.wait([sleep_task, wait_task], return_when=asyncio.FIRST_COMPLETED)
|
||||
for task in pending:
|
||||
task.cancel()
|
||||
|
||||
if self.guild and self.guild.voice_client:
|
||||
await self.guild.voice_client.disconnect(force=True)
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(
|
||||
f"Timed out while sending voice alert for timer {self!r}",
|
||||
exc_info=True
|
||||
)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
f"Exception occurred while playing voice alert for timer {self!r}"
|
||||
)
|
||||
finally:
|
||||
if self.guild and self.guild.voice_client:
|
||||
await self.guild.voice_client.disconnect(force=True)
|
||||
|
||||
def stageline(self, stage: Stage):
|
||||
t = self.bot.translator.t
|
||||
@@ -777,7 +785,7 @@ class Timer:
|
||||
logger.info(f"Timer {self!r} has stopped. Auto restart is {'on' if auto_restart else 'off'}")
|
||||
|
||||
@log_wrap(action="Destroy Timer")
|
||||
async def destroy(self, reason: str = None):
|
||||
async def destroy(self, reason: Optional[str] = None):
|
||||
"""
|
||||
Deconstructs the timer, stopping all tasks.
|
||||
"""
|
||||
|
||||
@@ -145,13 +145,11 @@ class TimerOptionsUI(MessageUI):
|
||||
value = selected.values[0] if selected.values else None
|
||||
setting = self.timer.config.get('notification_channel')
|
||||
|
||||
if issue := await setting._check_value(self.timer.data.channelid, value):
|
||||
await selection.edit_original_response(embed=error_embed(issue))
|
||||
else:
|
||||
setting.value = value
|
||||
await setting.write()
|
||||
await self.timer.send_status()
|
||||
await self.refresh(thinking=selection)
|
||||
await setting._check_value(self.timer.data.channelid, value)
|
||||
setting.value = value
|
||||
await setting.write()
|
||||
await self.timer.send_status()
|
||||
await self.refresh(thinking=selection)
|
||||
|
||||
async def refresh_notification_menu(self):
|
||||
self.notification_menu.placeholder = self.bot.translator.t(_p(
|
||||
|
||||
Reference in New Issue
Block a user