From c04f5dab6a54e3bf4cd32bffc696aa1cc6649c30 Mon Sep 17 00:00:00 2001 From: TVanteeffelen Date: Tue, 10 Jun 2025 20:53:10 +0000 Subject: [PATCH] Added in detection of someone joining the call. --- bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bot.py b/bot.py index f7c2b33..c6b9aa5 100644 --- a/bot.py +++ b/bot.py @@ -13,6 +13,7 @@ from dotenv import load_dotenv load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') PREFIX = os.getenv('BOT_PREFIX') +CHANNEL = os.getenv('BOT_CHANNEL') #Sets Discord intents. intents = discord.Intents.default() @@ -72,5 +73,14 @@ async def on_message(message): await message.channel.send(response) +@bot.event +async def on_voice_state_update(member, before, after): + + #Sends a message when someone joins any voice channel. + if before.channel is None and after.channel is not None: + channel = discord.utils.get(member.guild.text_channels, name=CHANNEL) #Finds a channel named in the .env file. + if channel: #If the channel exists. + await channel.send(f"{member.mention} joined {after.channel.name}!") + # Run the bot with your token bot.run(TOKEN) \ No newline at end of file