I want my discord bot to create an invite link to join the voice channel that the person who called the command is in.
@client.command()
async def voiceinvite(ctx):
if ctx.author.voice:
await ctx.send(ctx.message.author.voice.create_invite(max_age=120, max_uses=10))
else:
await ctx.send("Join a voice channel")
I've tried this but there's an error about references.
First, you should include the error message you got so we can figure out what is wrong
But as for the question:
The problem here is that you're trying to call
create_invite()
on aVoiceState
object. You need to call it on aVoiceChannel
object as documented in the docs.The solution would be:
API Reference
Next time, Please include the error when there is one. It helps people answer questions as errors have information about the problem and sometimes even the solution itself!