我试图让我的机器人为当前所在的公会创建一个临时的即时邀请。这可能吗? (该机器人将是公开的,因此会在很多行会中使用)
如果是这样,我正在寻求帮助<3
(对不起,如果这很容易编写代码。我仍在学习js; D)
答案 0 :(得分:0)
您可以使用GuildChannel.createInvite()
。这是一个示例:
// ASSUMPTIONS:
// message is the message that triggered the command
// the channel of the invite will be the channel where the message has been sent
async function replyWithInvite(message) {
let invite = await message.channel.createInvite({
maxAge: 10 * 60 * 1000 //maximum time for the invite, in milliseconds
maxUses: 1 //maximum times it can be used
}, `Requested with command by ${message.author.tag}`).catch(console.log);
message.reply(invite ? `Here's your invite: ${invite}` : "There has been an error during the creation of the invite.");
}
您可以通过添加参数来更改频道。请注意,只有在漫游器有权创建邀请的情况下,此选项才起作用。