0
votes
import discord
from discord.ext.commands import Bot
from discord.ext import commands,tasks
from discord.utils import get
from discord import Game

client = Bot(command_prefix = BOT_PREFIX)

@client.command()
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = await channel.connect()
    await ctx.send('Joined {}'.format(channel))

I just wanted to make a simple method that allows my discord bot to join a channel. I have looked at multiple threads and some of them are outdated because they were before discord.py migrated to v1.0. I have used type() and dir() to check what type the channel is and also see what methods it has. I compared it to the API from discord.py and a problem I found was that the dir() made a field called connect but the API shows that the channel object has a method called connect(). I am stuck at the moment trying to figure out how to make the discord bot join as it seems the connect() method does not allow me to connect as it does not allow me to continue with the method after I try using that connect() method. All help is appreciated! :)

1

1 Answers

0
votes

Remove the message from channel = ctx.message.author.voice.channel. Test this :)

channel = ctx.author.voice.channel
voice = await channel.connect()
await ctx.send('Joined {}'.format(channel))