0
votes

I'm trying to get my discord bot to connect to a voice channel like this currently:

@client.event
async def on_message(message):
message.content = message.content.lower()
if message.author == client.user:
    return

if '-skip' in message.content:
    await message.author.channel.connect
    await message.channel.send (f"-p scotland forever")
    await disconnect

Basically I want it to join a voice channel from the message author when they send the message "-skip" and then my bot joins, says -p scotland forever in chat, and then leaves. I get an error message saying things like "channel" not defined or "connect" not defined, ive tried doing it a few different ways, I think i just havent imported a plugin or whatever and thats probably my issue, but idk what plugin thing to use. Any help would be appreciated.

2
You might find this example helpful on how to get a basic music bot up and running.InsertCheesyLine

2 Answers

0
votes

Try this:

@client.event
async def on_message(message):
    message.content = message.content.lower()
    if message.author == client.user:
        return

    if '-skip' in message.content:
        channel = message.author.voice.channel
        if channel is not None:
            await channel.connect()
            await message.channel.send (f"-p scotland forever")
            await client.voice_clients[0].disconnect()
        else:
            await message.channel.send ("You need to join to voice channel")
0
votes

Try this

@commands.command()
async def join_voice(self, ctx):
    connected = ctx.author.voice
    if connected:
        await connected.channel.connect(put vc id here)

It may work I guess?