Added in detection of someone joining the call.

This commit is contained in:
Tanner Van Teeffelen 2025-06-10 20:53:10 +00:00
parent 5c226105d1
commit c04f5dab6a

10
bot.py
View file

@ -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)