Last active
October 5, 2021 05:31
-
-
Save lancepioch/f1d7a3b18bc1bffc9d3aaaa5934d511f to your computer and use it in GitHub Desktop.
Plays a sound when a user joins a voice channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import discord | |
from dotenv import load_dotenv | |
load_dotenv() | |
TOKEN = os.getenv('DISCORD_TOKEN') | |
client = discord.Client() | |
@client.event | |
async def on_member_join(user): | |
voice_channel = user.voice.voice_channel | |
if voice_channel == None | |
await client.say('User is not in a channel.') | |
return | |
vc = await client.join_voice_channel(voice_channel) | |
player = vc.create_ffmpeg_player('tacobell.mp3') | |
player.start() | |
while not player.is_done(): | |
await asyncio.sleep(1) | |
player.stop() | |
await vc.disconnect() | |
client.run(TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment