【发布时间】:2020-11-10 01:07:21
【问题描述】:
我能否检测到特定的人(我有 id)是否加入了随机语音频道并将我的机器人发送到该频道?我查了很多论坛和文档,但对如何做到这一点一无所知。
我有一个活动来检查特定的人是否加入了语音频道 - 没关系。 但我无法将我的机器人发送到那里,因为我不知道他们加入了哪个频道。
【问题讨论】:
我能否检测到特定的人(我有 id)是否加入了随机语音频道并将我的机器人发送到该频道?我查了很多论坛和文档,但对如何做到这一点一无所知。
我有一个活动来检查特定的人是否加入了语音频道 - 没关系。 但我无法将我的机器人发送到那里,因为我不知道他们加入了哪个频道。
【问题讨论】:
on_voice_state_update(member, before, after)
@client.event
async def on_voice_state_update(member, before, after):
if after is not None and member.id == the_id:
# check if bot is not already in the voice channel (im not sure how to) and then join it if not
【讨论】:
after 携带用户当前所在的频道。after 是discordpy.readthedocs.io/en/latest/…
if after.voice.voice_channel is not None and member.id == "guy's id": AttributeError: 'VoiceState' object has no attribute 'voice'