Discord.py重写 - 如何发出公会邀请

Discord.py REWRITE - How to make a Guild Invite

我正在尝试让我的机器人创建邀请

invite = await bot.create_invite()

这会报错'bot' object has no Attribute 'create_invite'
我正在使用 Discord.py 重写。

提前致谢!

使用channel.create_invite().

示例:

invite = await message.channel.create_invite()

您需要指定您发出邀请的目的,因为该机器人当前没有邀请目标:

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

参考文献:

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