【发布时间】:2021-03-14 23:08:00
【问题描述】:
我找不到解决方案,所以我在这里。 我在 discord.py rewrite 中为我的 discord 服务器制作了一个机器人,我想实现当用户加入语音频道时我的机器人会说些什么的功能。
我什至无法让机器人加入语音聊天,因为它会导致所有可能的错误。提前致谢。
这些是我尝试过的:
@bot.command()
async def join_voice(self, ctx):
connected = ctx.author.voice
if connected:
await connected.channel.connect()
还有这个
@bot.command(pass_context=True)
async def join(ctx):
author = ctx.message.author
channel = author.voice_channel
await bot.join_voice_channel(channel)
他们都给出了这个错误
discord.ext.commands.errors.CommandInvokeError: Command raised an exception:
AttributeError: 'Member' object has no attribute 'voice_channel'
【问题讨论】:
-
嗨,欢迎来到 StackOverflow!关于您的问题,您能否提供一些您尝试过的代码以及您可能遇到的任何错误,以便我们更好地帮助您?
标签: python discord bots discord.py discord.py-rewrite