I recently started to learn python by making bots for Discord. Now I'm making a Music bot but I got an error and couldn't find where the error is. Can you guys help, please? It joins the channel but gives the Error3 in Chat and if I write !Play (URL) again, it gives the Error 4 in chat.
Here is the Code:
import discord
client = discord.Client ()
@client.event
async def on_ready():
print(client.user.name)
print("-------------------")
@client.event
async def on_message(message):
if message.content.startswith("!stop"):
try:
voice_client = client_voice_in(message.server)
await voice_client.disconnect()
except AttributeError:
await client.send_message(message.channel, "I'm not connected.")
except Exception as Hugo:
await client.send_message(message.channel, "Error1_______|type|_______".format(type=Hugo))
if message.content.startswith("!play"):
try:
yt_url = message.content[6:]
if client.is_voice_connected(message.server):
try:
voice = client.voice_client_in(message.server)
players[message.server.id].stop()
player = await voice.create_ytdl_player(yt_url, before_options=" -reconnect 1 -reconnect_streamed 1"
" -reconnect_delay_max 5")
players[message.server.id] = player
player.start()
except Exception as e:
await client.send_message(message.server, "Error2______[Error]".format(error=e))
if not client.is_voice_connected(message.server):
try:
channel = message.author.voice.voice_channel
voice = await client.join_voice_channel(channel)
player = await voice.create_ytdl_player(yt_url, before_options=" -reconnect 1 -reconnect_streamed 1"
" -reconnect_delay_max 5")
players[message.server.id] = player
player.start()
except Exception as e:
await client.send_message(message.channel, "Error3____[error]".format(error=e))
except Exception as e:
await client.send_message(message.channel, "Error4________[error]".format(error=e))
client.run("I erased the token number before sharing, it's not the problem")