如何在嵌入中显示歌曲的标题



这是我的代码(机器人程序的答案是西班牙语(我试图把self.info['title']放在嵌入描述中,但说'music_cog' object has no attribute 'info':是一个错误

def search_yt(self, item):
with YoutubeDL(self.YDL_OPTIONS) as ydl:
try: 
self.info = ydl.extract_info("ytsearch:%s" % item, download=False)['entries'][0]
except Exception: 
return False
return {
'source': self.info['formats'][0]['url'], 
'title': self.info['title'],
'channel': self.info['channel']
}
@client.command()
async def p(self, ctx, *args):
embed = discord.Embed(
title = 'Reproduciendo 🎵',
description = 'song_title'
)
query = " ".join(args)

voice_channel = ctx.author.voice.channel
if voice_channel is None:
await ctx.send("Antes debes meterte a un canal de voz")
else:
song = self.search_yt(query)
if type(song) == type(True):
await ctx.send("Hubo un error al intentar reproducir la canción >-<")
else:
await ctx.send(embed=embed)
await ctx.send("**Canción agregada con exito**")
self.music_queue.append([song, voice_channel])

if self.is_playing == True:
await ctx.send('La canción se agrego a la lista de reproducción')
else:
await self.play_music()
await ctx.send("**Reproduciendo**")

在嵌入初始化之前写入song = self.search_yt(query)并创建如下嵌入:

embed = discord.Embed(
title = "Reproduciendo 🎵",
description = song['title']
)

最新更新