import discord
from discord.ext import commands
TOKEN = 'YOUR_BOT_TOKEN_HERE'
NEW_PROFILE_TOKEN = 'NEW_PROFILE_TOKEN_HERE'
intents = discord.Intents.default()
intents.voice_states = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()
@bot.command()
async def leave(ctx):
await ctx.voice_client.disconnect()
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.content == 'ping':
await message.channel.send('pong')
@bot.event
async def on_voice_state_update(member, before, after):
if member == bot.user:
return
if before.channel is None and after.channel is not None:
voice_client = await after.channel.connect()
source = discord.FFmpegPCMAudio('music.mp3')
voice_client.play(source)
bot.run(NEW_PROFILE_TOKEN)