首页 > 解决方案 > 如何在 discord.py 中检查以前制作的不和谐邀请?

问题描述

每当运行此命令时,都会发出新的不和谐邀请。有没有办法让机器人检查以前发出的邀请?

@client.command()
async def invite(ctx):
    link = await ctx.channel.create_invite()
    sender = ctx.message.author.id
    await ctx.author.send(f"<@{sender}>, your invite link is {link}")
    await ctx.send(f"<@{ctx.message.author.id}>, an invite link has been sent to your DMs!")

标签: python-3.xdiscorddiscord.py

解决方案


使用:await guild.invites() https ://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.invites 你可以很容易地获得该公会中所有邀请的列表


推荐阅读