Added in detection of someone joining the call.
This commit is contained in:
parent
5c226105d1
commit
c04f5dab6a
1 changed files with 10 additions and 0 deletions
10
bot.py
10
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)
|
||||
Loading…
Add table
Reference in a new issue