예제 #1
0
파일: music.py 프로젝트: nwakefield1/swab
 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()
예제 #2
0
파일: music.py 프로젝트: nwakefield1/swab
    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()