我正在尝试制作一个在语音频道中播放音乐的不和谐机器人。它连接到语音通道,但不播放任何内容。它还在控制台中给出错误。
我在 Windows 上,我正在使用 discord.py 重写。
我的代码:
import discord, random, datetime, asyncio, nacl, ffmpeg
TOKEN = 'What token'
client = discord.Client()
@client.event
async def on_message(message):
if message.content.lower() == '$play':
if message.content.lower() == '$play':
channel = client.get_channel(547155964328149007)
vc = await channel.connect()
vc.play(discord.FFmpegPCMAudio('mp3.mp3'), after=lambda e: print('done', e))
vc.is_playing()
vc.pause()
vc.resume()
vc.stop()
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
client.run(TOKEN)
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "D:\Python35\lib\site-packages\discord\client.py", line 218, in _run_event
await coro(*args, **kwargs)
File "discord_bot.py", line 90, in on_message
vc.play(discord.FFmpegPCMAudio('mp3.mp3'), …Run Code Online (Sandbox Code Playgroud)