My Discord Bot is not working :(

My Discord Bot is not working :(
0

#1

I wrote a python3 code for my discord server, but it didn’t work .
Please help me fix it !

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import youtube_dl
import asyncio
import time
import os

Client = discord.Client()
client = commands.Bot(command_prefix = '.')

players = {}

@client.event
async def on_ready():
    print ("Hi")
    await client.change_presence(game=discord.Game(name="Music for everyone !"))
    
@client.event
async def on_message(message):
    if message.content.startswith('.join'):
        channel = ctx.message.author.voice.voice_channel
        await client.join_voice_channel(channel)
    if message.content.startswith('.leave'):
        server = ctx.message.server
        voice_client = client.voice_client_in(server)
        await voice_client.disconnect()
    
@client.command(pass_context=True) 
async def play(ctx, url):
    server = ctx.message.server
    voice_client = client.voice_client_in(server)
    player = voice_client.create_ytdl_player(url)
    players[server.id] = player
    player.start()
    
    
client.run(os.getenv('BOT_TOKEN'))

#2

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

Note: Backticks are not single quotes.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


Also, apologies post needing to be approved: the automatic forum filter kicked in, assuming because it mentions bots a lot.