02import15 10listen 02import15 10discord 02from15 10discord10.10ext15 02import commands 02import15 10websockets 02import15 10json 02import15 10time 02import15 10asyncio b = 05"05" 02class15 07listen: 15 05"""Beta. Please don't run yet.""" 02def15 07__init__(10self, bot): 10self.bot = bot 02async 02def15 07whiile(websocket, ctx, timee): time.sleep(timee/021000) 02await websocket.send(05'05{05 05"05op05"05: 9 }05') c = json.loads(02await websocket.recv()) c = json.loads(02await websocket.recv()) 02if c[05"05op05"] == 021: 02await ctx.send(05"05Currently playing: 05" + c[05"05d05"][05"05song05"][05"05title05"]) 14@commands.command() 02async 02def15 07listen_moe(10self, ctx): 15# if ctx.message.author.voice.is_connected() == True: 15# await ctx.message.author.voice.disconnect() 02if ctx.message.author.voice == 02None: 02await ctx.send(05"05I05'05m only going to play listen.moe if you05'05re there to listen with me. ;-;05") 02else: a = 02await ctx.message.author.voice.channel.connect() a.play(discord.FFmpegPCMAudio(05"05https://listen.moe/stream05")) 02async 02with websockets.connect(05"05wss://listen.moe/gateway05") 02as web: 02await web.send(05'05{05 05"05op05"05: 0, 05"05d05"05: 05{05"05auth05"05: 05"05"05 } }05') b = json.loads(02await web.recv()) c = json.loads(02await web.recv()) 02await ctx.send(05"05Joined Listen.moe! Currently playing: 05" + c[05"05d05"][05"05song05"][05"05title05"]) lsock = listen.whiile(web, ctx, b[05"05d05"][05"05heartbeat05"]) asyncio.get_event_loop().run_until_complete(lsock) asyncio.get_event_loop().run_forever() 14@commands.command() 02async 02def15 07stop(10self, ctx): 02if ctx.voice_client: ctx.voice_client.source.cleanup() 02await ctx.voice_client.disconnect() 02def15 07setup(bot): bot.add_cog(listen(bot))