def test_create_palylist(self): wynk = MusicPlayer( 10, 9, 4, 'Harshi', 'WYNK08', 'premium', ['Pachai Nirame'], ['descpasito'], ['Tamil', 'Hindi', 'English'], 1, ['Premium', 'Free', 'Subscribed'], ['Anirudh', 'ARR', 'Ankit Tiwari'], { 'Anirudh': ['Yaanji', 'VIP'], 'Dhanush': ['Maruvarthai', 'Vada chennai', 'Visiri'], 'Hindi': ['ADHM', 'Dekthe', 'Barish'] }, ['Nostalgic', 'Love', 'English'], []) song = WynkSongs('mazhai kuruvi', 'MK', 4, 'ARR', 'Tamil', 'STR', 'CCV', '5 mins', 'xx', 10) song = wynk.add_to_playlist('Pachai Nirame') self.assertNotEqual(song, ['Mazhai kuruvi'])
async def on_message(message: Message): if message.author.id == bot.user.id: return control_channel = get_bot_control_channel(message.server.channels) if not control_channel: return if control_channel.id != message.channel.id: return if not message.content: await bot.delete_message(message) return content = message.content.split(' ') command = content[0].lower() if len(content) > 1: args = content[1:] else: args = None if message.channel.is_private: if command != 'help': await bot.send_message( message.author, "I didn't get that. But there are available commands:") await bot.send_message(message.author, help_message) return m_player = bot.music_players.get(message.server.id, None) user_voice_channel = message.author.voice.voice_channel bot_voice_channel = bot.voice_channels.get(message.server.id, None) if command == 'summon' or command == 'summoning jutsu': if user_voice_channel: if m_player: await m_player.voice_client.disconnect() m_player.voice_client = await bot.join_voice_channel( user_voice_channel) else: voice_client = await bot.join_voice_channel(user_voice_channel) m_player = MusicPlayer( voice_client, next_song_event_generator(control_channel), settings.MUSIC_DIRECTORY, settings.DEFAULT_VOLUME) bot.music_players.update({message.server.id: m_player}) bot.voice_channels.update( {message.server.id: user_voice_channel}) username = message.author.nick if message.author.nick else message.author.name await bot.send_message(control_channel, 'At your service, sir {}.'.format(username)) else: await bot.send_message(control_channel, 'Unable to join: unknown voice channel!') elif command == 'help': await bot.send_message(message.author, help_message) elif command == 'clear_messages': if not message.author.permissions_in(control_channel).manage_messages: return await bot.purge_from(control_channel, limit=50) elif command == 'update_songs': if not message.author.permissions_in(control_channel).manage_messages: return m_player.update_songs() elif m_player and user_voice_channel == bot_voice_channel: if command == 'bye': await bot.disconnect_from_server(message.server.id) elif command == 'play': success = await m_player.play() if not success: await incorrect_message(message) elif command == 'seek' and args: await m_player.seek(args[0]) elif command == 'volume': if args: success = m_player.set_volume(args[0]) if not success: await incorrect_message(message) else: await bot.send_message( control_channel, 'New volume is {}%'.format(m_player.get_volume())) else: await bot.send_message( control_channel, 'Current volume is {}%'.format(m_player.get_volume())) elif command == 'pause': m_player.pause() elif command == 'stop': await bot.change_presence(game=discord.Game( name='v. {}'.format(settings.BOT_VERSION))) m_player.reset_player() elif command == 'next': await m_player.play_next_song() elif command == 'prev': await m_player.play_previous_song() elif command == 'add' and args: success = m_player.add_to_playlist(args[0]) if not success: await incorrect_message(message) elif command == 'delete': if args: song = await m_player.delete_from_playlist(args[0]) else: song = await m_player.delete_from_playlist() if not song: await incorrect_message(message) else: # todo: execute playlist command here await bot.send_message( control_channel, '***{}.** {} was deleted from playlist!*'.format( args[0], song.title)) elif command == 'playlist': plist_msg = '' i = 1 for song_title in m_player.get_playlist_titles(): if m_player.current_song_id == i - 1: song_title = '**' + song_title + '**' else: song_title = '*' + song_title + '*' plist_msg += '**{}**. {}\n'.format(i, song_title) i += 1 if plist_msg: await bot.send_message(control_channel, plist_msg) else: await bot.send_message(control_channel, '*The playlist is empty!*') elif command == 'select' and args: try: await m_player.select_song(args[0]) except Exception: await incorrect_message(message) else: await incorrect_message(message) else: await incorrect_message(message)