OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Discord Nextcord bot How to detect which voice channel the user joined?

  • Thread starter Thread starter Kkoko Koko
  • Start date Start date
K

Kkoko Koko

Guest
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 more or less if i specify the name of the voice channel, except that no matter which voice channel i join, it will always mention "Lobby" in the chat.

I would like the event to detect the voice channel where the user just joined, so this could work for every existing and future voice channels, especially once my bot would be used on multiple servers as well.

Code:
@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}!')
<p>So, i would like my bot to send a message tagging the user and the voice channel, when somebody joins a voice channel.</p>
<p>So far this is my code and it works more or less if i specify the name of the voice channel, except that no matter which voice channel i join, it will always mention "Lobby" in the chat.</p>
<p>I would like the event to detect the voice channel where the user just joined, so this could work for every existing and future voice channels, especially once my bot would be used on multiple servers as well.</p>
<pre><code>@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}!')
</code></pre>
 

Latest posts

Top