Skip to content

Commit

Permalink
Fix NoneType object error
Browse files Browse the repository at this point in the history
self.encoder is initialized for the first time with a play function.
If called before the play function is done an error will occur.
  • Loading branch information
rinjugatla authored and Lulalaby committed Jul 4, 2022
1 parent 0492613 commit 4d26ae2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discord/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ def send_audio_packet(self, data: bytes, *, encode: bool = True) -> None:

self.checked_add("sequence", 1, 65535)
if encode:
if not self.encoder:
self.encoder = opus.Encoder()
encoded_data = self.encoder.encode(data, self.encoder.SAMPLES_PER_FRAME)
else:
encoded_data = data
Expand Down

0 comments on commit 4d26ae2

Please sign in to comment.