我正在尝试让我的不和谐机器人当前连接到这样的语音通道:
@client.event
async def on_message(message):
message.content = message.content.lower()
if message.author == client.user:
return
if '-skip' in message.content:
await message.author.channel.connect
await message.channel.send (f"-p scotland forever")
await disconnect
基本上,我希望它加入消息作者的语音通道,当他们发送消息“ -skip”,然后我的机器人加入时,-p scotland永远在聊天中说,然后离开。我收到一条错误消息,提示未定义“通道”或“连接”之类的东西,我尝试以几种不同的方式进行操作,我想我还没有导入插件或其他什么东西,多数民众赞成在我的问题,但idk是什么插件呢?使用。任何帮助将不胜感激。
答案 0 :(得分:0)
尝试一下:
@client.event
async def on_message(message):
message.content = message.content.lower()
if message.author == client.user:
return
if '-skip' in message.content:
channel = message.author.voice.channel
if channel is not None:
await channel.connect()
await message.channel.send (f"-p scotland forever")
await client.voice_clients[0].disconnect()
else:
await message.channel.send ("You need to join to voice channel")
答案 1 :(得分:0)
试试这个
@commands.command()
async def join_voice(self, ctx):
connected = ctx.author.voice
if connected:
await connected.channel.connect(put vc id here)
可能有用 我猜?