Discord机器人加入AFK频道后无法自行解除静音问题求助
Discord机器人加入AFK频道后无法解除静音的问题
我正在为私人服务器开发一款Discord机器人,需求是当有人加入AFK频道时播放MP3文件。该AFK频道会在用户加入时自动将其静音,机器人也不例外。机器人已拥有管理员权限,理论上具备自行解除静音的权限,但我始终无法让机器人加入频道后解除静音。
初始代码
@client.event async def on_voice_state_update(member, before, after): if before.channel and after.channel: channel = after.channel randomSong = random.choice(os.listdir("file")) if channel.id == #id: voice = await channel.connect() source = FFmpegPCMAudio(f"{randomSong}") voice.play(source) print(randomSong)
修改后的代码
查阅文档后得知connect()方法可传入self_mute参数,我将其设为False,但机器人加入语音频道后仍处于静音状态。也尝试过查找相关解决方案,不过问题依然存在。
@client.event async def on_voice_state_update(member, before, after): if before.channel and after.channel: channel = after.channel randomSong = random.choice(os.listdir("file")) if channel.id == #id: voice = await channel.connect(self_mute=False) source = FFmpegPCMAudio(f"{randomSong}") voice.play(source) print(randomSong)
内容的提问来源于stack exchange,提问作者War
相关产品推荐
相关产品推荐

