【发布时间】:2021-07-08 05:26:58
【问题描述】:
我正在尝试使用 discord.py 将我的机器人连接到语音频道,但它对我来说效果不佳...关于如何改进它的任何帮助?
@bot.command(pass_context=True)
async def join(ctx):
channel = ctx.author.voice.channel
await bot.join_voice_channel(channel)
错误:
Ignoring exception in command join:
Traceback (most recent call last):
File "C:\Users\matan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/matan/Desktop/python/discord bot 1/Main.py", line 926, in join
await bot.join_voice_channel(channel)
AttributeError: 'Bot' object has no attribute 'join_voice_channel'
我也有这个代码:
@bot.command()
async def play(ctx, url : str, channel = discord.VoiceChannel):
await channel.connect()
它没有错误 - 它只是什么都不做......
【问题讨论】:
-
我想你的意思是
channel: discord.VoiceChannel,而不是一个任务=
标签: python discord discord.py