我有一个不和谐的bot,可以播放在线广播节目,并且我正在尝试实现一个功能(命令),该功能将显示该机器人正在播放的当前电台,但会停留一半。
@bot.command()
async def current(ctx):
voice = get(bot.voice_clients, guild=ctx.guild)
station = voice.source
if voice.is_playing():
print(f'Currently playing {station}')
await ctx.send(f'Current station {station}.')
机器人接收站流的方式是使用直接音频流URL,这是一个站的示例:
@bot.command(aliases=['1'])
async def core(ctx):
global player
channel = ctx.message.author.voice.channel
try:
player = await channel.connect()
except:
pass
if player.is_playing():
player.stop()
player.play(FFmpegPCMAudio('http://serv.coreradio.ru:8000/coreradio'))
await ctx.channel.send('Playing: Core radio!\n')
await ctx.send(warning)
因此该命令确实可以工作并返回音频源,但是问题在于它以字符串形式返回,该字符串是无法理解的字符(discord.player.FFmpegPCMAudio对象位于0x046325B0)。
我的问题是如何将其转换为显示实际的电台播放情况?