fix (timers): Voice event task creation.
This commit is contained in:
@@ -184,14 +184,14 @@ class TimerCog(LionCog):
|
||||
joining = self.get_channel_timer(after.channel.id) if after.channel else None
|
||||
|
||||
tasks = []
|
||||
if leaving:
|
||||
tasks.append(leaving.update_status_card())
|
||||
if leaving is not None:
|
||||
tasks.append(asyncio.create_task(leaving.update_status_card()))
|
||||
if joining is not None:
|
||||
joining.last_seen[member.id] = utc_now()
|
||||
if not joining.running and joining.auto_restart:
|
||||
tasks.append(joining.start())
|
||||
tasks.append(asyncio.create_task(joining.start()))
|
||||
else:
|
||||
tasks.append(joining.update_status_card())
|
||||
tasks.append(asyncio.create_task(joining.update_status_card()))
|
||||
|
||||
if tasks:
|
||||
try:
|
||||
|
||||
@@ -447,6 +447,7 @@ class Timer:
|
||||
|
||||
with open(alert_file, 'rb') as audio_stream:
|
||||
finished = asyncio.Event()
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
def voice_callback(error):
|
||||
if error:
|
||||
@@ -456,7 +457,7 @@ class Timer:
|
||||
logger.exception(
|
||||
f"Callback exception occured while playing voice alert for timer {self!r}"
|
||||
)
|
||||
finished.set()
|
||||
loop.call_soon_threadsafe(finished.set)
|
||||
|
||||
voice_client.play(discord.PCMAudio(audio_stream), after=voice_callback)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user