当一个成员连接到一个语音频道时做点什么-discord.py



我试着根据"on_member_join";函数,但这不起作用。那么,我该怎么做呢?

@client.event
async def on_member_connect(member):
channel = discord.utils.get(member.guild.voice_channels, name="channel-name")
print("blabla")

根据文档,on_member_join不是在成员加入渠道时调用的,而是在用户加入公会/服务器时调用的。

on_member_connect不是discord.py上的事件,您要查找的是on_voice_state_update

@client.event
async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel:
# User has connected to a VoiceChannel
channel = after.channel
# Code here...

最新更新