async def join(context, channel_name : str): global radio if bot.is_voice_connected(): await bot.say('Already connected to a voice channel') check = lambda c: c.name == channel_name and c.type == discord.ChannelType.voice channel = discord.utils.find(check, context.message.server.channels) if channel is None: await bot.say('Cannot find a voice channel by that name.') await bot.join_voice_channel(channel)
async def play(ctx): global radio if radio.player is not None and radio.player.is_playing(): await bot.say('Already playing a song') return if len(radio.songs) == 0 and ctx.invoked_subcommand is None: await radio.random_q() while True: if not bot.is_voice_connected(): await bot.say('Not connected to a voice channel') return radio.play_next_song.clear() #radio.current = await radio.songs.get() radio.current = radio.songs.popleft() #print(radio.current) radio.player = bot.voice.create_ffmpeg_player(radio.copycom.direct_link(radio.current), after=radio.toggle_next_song, options="-headers '{}' -loglevel debug -report".format(radio.copycom.get_headers_str())) radio.player.start() fmt = 'Playing song "{0}"' await bot.say(fmt.format(unquote(radio.current.split('/')[-1]))) #await bot.say(fmt.format(unquote(radio.current))) await radio.play_next_song.wait()