我试图创建一个不和谐的机器人,当它被添加到上述公会并将其发送到控制台时,将创建一个邀请到公会的第一个通道。
我的代码(它不工作):
client.on("guildCreate", guild => {
const channel = Array.from(guild.channels).sort((a, b) => a.calculatedPosition - b.calculatedPosition)[0];
channel.createInvite({
unique: true
})
.then(invite => {
console.log(`Joined to: ${guild.name} Invite: https://discord.gg/${invite.code}`);
})
});发布于 2020-08-12 06:21:56
// Listeing to the guildCreate event.
client.on("guildCreate", guild => {
// Filtering the channels to get only the text channels.
const Channels = guild.channels.cache.filter(channel => channel.type == "text");
// Creating an invite.
Channels.first().createInvite({
maxUses: 1,
unique: true
}).then(invite => {
console.log(`[INVITE] I've created an invite for ${guild.id}:${guild.name} - ${invite.url}`);
});
});https://stackoverflow.com/questions/63370228
复制相似问题