async def play_song_wrapper(self, voice_client: discord.VoiceClient, channel: discord.VoiceChannel = None): try: self.play_song(voice_client, channel) except discord.errors.ClientException as e: if 'Not connected to voice' in str(e): channel.connect()
def play_song(self, voice_client: discord.VoiceClient, channel: discord.VoiceChannel = None) -> None: """ Plays the first song in the playlist queue. :param voice_client: The discord VoiceClient that the bot should play into. :param channel: A channel to connect to if the bot is currently not in one. :return: None """ try: print(self.playlist) source = discord.FFmpegOpusAudio( self.playlist[0], options={'use_wallclock_as_timestamps': True}) voice_client.play(source, after=self.play_after) self.playlist.pop(0) self.current_song_playing = self.playlist_data.pop(0) self.song_started_at = datetime.datetime.now() except discord.errors.ClientException as e: if 'Not connected to voice' in str(e): channel.connect()