创建邀请并将其发送给不在 server/guild 中的用户

Creating an invite and send it to an user that is not in your server/guild

我有一个用户注册的网站。在注册过程中,我要求他们提供他们的 discord 用户,让他们访问我们拥有的 discord 社区。

是否可以为我的 guild/channel 创建邀请并使用 discord.js 将其发送给不和谐的用户?我需要这个邀请是唯一的并且仅限于一次使用。因此,每次用户在该站点注册时,我都需要创建一个新的。

可以创建一个独特的邀请,但您不能将其发送给 Discord 内的用户,您需要在您的网页中显示 link:机器人无法向不在相互公会,防止垃圾邮件。

要创建邀请,您可以使用 GuildChannel.createInvite() 方法:

let newInvite = await channel.createInvite({
  maxUses: 1, // After one use it will be void
  unique: true, // That tells the bot not to use an existing invite so that this will be unique
  maxAge: 86400 // By default invites last 24 hours. If you want to change that, modify this (0 = lasts forever, time in seconds)
});