如何使discord.py bot在用户加入特定语音频道时在特定频道中发送嵌入消息
我正在学习discord.py,我想让发送嵌入式消息的bot像。(@user has joined!)只在特定的文本频道中加入,例如当用户加入特定的语音频道时(music.vc)如何使discord.py bot在用户加入特定语音频道时在特定频道中发送嵌入消息,discord.py,Discord.py,我正在学习discord.py,我想让发送嵌入式消息的bot像。(@user has joined!)只在特定的文本频道中加入,例如当用户加入特定的语音频道时(music.vc) 像这样 当用户加入时 同时 当用户离开时 请原谅多次编辑。这是否回答了您的问题? @client.event async def on_voice_state_update(member, before, after): channelId = 1234567891011 # Your text cha
- 像这样
- 同时
请原谅多次编辑。这是否回答了您的问题?
@client.event
async def on_voice_state_update(member, before, after):
channelId = 1234567891011 # Your text channel id here
voiceChannelId = 1234567891011 # Your voice channel id here
@bot.event
async def on_voice_state_update(member, before, after):
if ((before.channel != None and before.channel.id == voiceChannelId) or (after.channel != None and after.channel.id == voiceChannelId)): # if connected/disconected to voiceChannelId channel
channel = bot.get_channel(channelId) # gets channel object
if (before.channel == None and after.channel != None): # if user connect
channel.send(f"{member.mention} connected to voice {after.channel.name}") # send message to channel
elif (before.channel != None and after.channel == None): # if user disconnect
channel.send(f"{member.mention} disconnect from voice {before.channel.name}") # send message to channel