【问题标题】:Add permissions to channel for user为用户添加频道权限
【发布时间】:2018-07-15 17:43:27
【问题描述】:

我最近将这个 Discord 机器人添加到我的服务器:https://github.com/critcola/discord-auto-grouping

它运行良好,我对其进行了少许修改,以确保它根据用户名、用户限制和服务器中的某个类别创建房间。

我的最后一个编辑(我似乎无法理解)是,在创建频道时,将用户添加到权限并仅允许他们对频道的完全管理权限。

以下是我迄今为止尝试过的,它没有产生任何错误,只是没有做任何事情,因此我现在被难住了!

任何帮助将不胜感激。

// 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);
    }
}

【问题讨论】:

  • 来自Permissions.js,看起来MANAGE_PERMISSIONS 不是真正的权限。你也可以'ADMINISTRATOR': true吗?

标签: javascript node.js discord discord.js


【解决方案1】:

你犯了一个小错误。由于MANAGE_PERMISSIONS 是无效权限, 你需要使用MANAGE_ROLES

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-01
    • 2010-12-24
    • 2018-12-24
    • 2021-09-01
    • 1970-01-01
    • 2021-02-08
    • 2021-01-31
    • 2020-02-28
    相关资源
    最近更新 更多