From 542c5897a69b533b6ab3ef537d0f991985b857e0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Mar 2020 20:43:14 +0100 Subject: [PATCH] Add a destroy method to Playables --- royalnet/serf/discord/playable.py | 4 ++++ royalnet/serf/discord/voiceplayer.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/royalnet/serf/discord/playable.py b/royalnet/serf/discord/playable.py index e7f678a6..e9b202d5 100644 --- a/royalnet/serf/discord/playable.py +++ b/royalnet/serf/discord/playable.py @@ -59,3 +59,7 @@ class Playable: should ``yield`` once before doing anything else.""" yield raise NotImplementedError() + + async def destroy(self): + """Clean up the Playable, as it is about to be replaced or deleted.""" + raise NotImplementedError() diff --git a/royalnet/serf/discord/voiceplayer.py b/royalnet/serf/discord/voiceplayer.py index 73a15ba8..b5468542 100644 --- a/royalnet/serf/discord/voiceplayer.py +++ b/royalnet/serf/discord/voiceplayer.py @@ -110,3 +110,7 @@ class VoicePlayer: log.error(error) return self._playback_ended_event.set() + + async def change_playing(self, value: Playable): + await self.playing.destroy() + self.playing = value