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