我最近将此 Discord 机器人添加到我的服务器:https://github.com/critcola/discord-auto-grouping
它工作得很好,我对它进行了轻微的修改,以确保它根据用户名创建一个房间,具有用户限制,并在我的服务器中的某个类别下。
我的最后一次编辑(我似乎无法理解)是,在创建 channel 时,将用户添加到权限中,并仅允许他们在 channel 上拥有完全的管理权限。
下面是我到目前为止所尝试过的,它没有产生任何错误,它只是没有做任何事情,因此我现在被难住了!
任何帮助将不胜感激。
// Check if the user entered a new channel.
if (member.voiceChannelID) {
const newChannel = member.guild.channels.get(member.voiceChannelID);
// If the user entered a game channel (prefixed with a game controller unicode emoji), group them into their own channel.
if (newChannel.name.startsWith(String.fromCodePoint('0x1F3AE'))) {
newChannel.clone(String.fromCodePoint('0x2501') + member.user.username + "'s Room", false)
.then(createdChannel => {
createdChannel.edit({
bitrate: 96000,
//position: newChannel.position + 0,
userLimit: 5,
parent: '409821646698971136'
})
//Set Permissions
.then(createdChannel.overwritePermissions(member.user.id,{'MANAGE_PERMISSIONS':true, 'MANAGE_CHANNELS':true}))
.then(createdChannel => {
member.setVoiceChannel(createdChannel)
.then(console.log('[' + new Date().toISOString() + '] Moved user "' + member.user.username + '#' + member.user.discriminator + '" (' + member.user.id + ') to ' + createdChannel.type + ' channel "' + createdChannel.name + '" (' + createdChannel.id + ') at position ' + createdChannel.position))
.catch(console.error);
})
.catch(console.error);
})
.catch(console.error);
}
}
最佳答案
你犯了一个小错误。由于 MANAGE_PERMISSIONS
是无效权限,
您需要使用MANAGE_ROLES
。
关于javascript - 为用户添加 channel 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48629843/