So, i would like my bot to send a message tagging the user and the voice channel, when somebody joins a voice channel.
So far this is my code and it works perfectly if i specify the name of the voice channel, however, i would like the event to detect the voice channel where the user just joined, so this could work for other voice channels as well without specifying the name of all of them, especially once my bot would be used on multiple servers.
@client.event
async def on_voice_state_update(member, before, after):
if not before.channel and after.channel:
channel = nextcord.utils.get(member.guild.channels, name="general")
voice_channel = nextcord.utils.get(member.guild.channels, name="Lobby")
await channel.send(f'I noticed that {member.mention} just joined {voice_channel.mention}!')
Kkoko Koko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.