python - ctx.send() 不适用于播放音乐
问题描述
我正在使用 Discord.py 制作 Discord Music Bot,但是当我运行 play 命令时,它可以正常播放,但 bot 没有发送它应该发送的消息:
@client.command(description = "Starts playing the specified song.")
async def play(ctx, *, track = 'track'):
# TURNS SEARCH RESULT INTO URL-------------------
search = list(track.split(" "))
query = "+".join(str(x) for x in search)
search_url = "https://www.youtube.com/results?search_query=" + query
html = urllib.request.urlopen(search_url)
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
url = "https://www.youtube.com/watch?v=" + video_ids[0]
#------------------------------------------------
player = music.get_player(guild_id = ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix = True)
if not ctx.voice_client.is_playing():
await player.queue(url)
await player.play()
video = YouTube()
await ctx.send("Now playing: " + video.title)
print("debug")
else:
await player.queue(url)
await ctx.send("The following song has been added to the queue: " + video.title)
谁能告诉我我可能做错了什么?我认为这很明显,但我似乎找不到。要播放音乐,我使用 DiscordUtils。此外,如果您有敏锐的眼光,您可能已经注意到print("debug")
代码是否到达那里,如果没有,控制台不会打印。
解决方案
推荐阅读
- javascript - ajax请求被防火墙阻止时如何跟踪?
- javascript - IOS中的水平滚动不起作用ReactJs
- jquery - 带有徽标移动的响应式导航栏问题
- c# - POS POLE Display-如何水平滚动内容?
- java - 如何防止 Oracle 中的“坏”日期?
- powershell - 从外部 URI 获取 JSON 对象中的值
- spotfire - 如何在 Web Player 中添加热图?
- jquery - Video.JS:如何在视频容器中间添加我自己的自定义播放和暂停按钮?
- html - 在右侧的输入字段内添加 fa eye 图标,这是响应式的
- java - 如何检查一个日期期间是否与另一个日期期间重叠