Discord.py REWRITE - How to make a Guild Invite

3.4k Views Asked by At

I am trying to make my bot create an invite

invite = await bot.create_invite()

This gives an error 'bot' object has no Attribute 'create_invite'
I am using the Discord.py Rewrite.

Thanks in advance!

3

There are 3 best solutions below

0
Diggy. On BEST ANSWER

You'll need to specify what you're making the invite for, because the bot doesn't currently have a target for the invite:

@bot.command()
async def createinv(ctx):
    invite = ctx.channel.create_invite()
    await ctx.send(f"Here's your invite: {invite}")

References:

0
chluebi On

Use channel.create_invite().

Example:

invite = await message.channel.create_invite()
0
Enzo Seschi On
@client.command()
async def invite(ctx):
    invite = await ctx.channel.create_invite()
    await ctx.send(f"Your invite is {invite}")