diff options
Diffstat (limited to 'discord/voice_client.py')
| -rw-r--r-- | discord/voice_client.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py index 64dd6538..e1e6fce7 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -359,9 +359,22 @@ class VoiceClient: @property def source(self): - """Optional[:class:`AudioSource`]: The audio source being played, if playing.""" + """Optional[:class:`AudioSource`]: The audio source being played, if playing. + + This property can also be used to change the audio source currently being played. + """ return self._player.source if self._player else None + @source.setter + def source(self, value): + if not isinstance(value, AudioSource): + raise TypeError('expected AudioSource not {0.__class__.__name__}.'.format(value)) + + if self._player is None: + raise ValueError('Not playing anything.') + + self._player._set_source(value) + def send_audio_packet(self, data, *, encode=True): """Sends an audio packet composed of the data. |