锁定命令不锁定频道?

时间:2019-07-12 23:12:19

标签: javascript discord.js

所以这是一个锁定命令,命令运行正常,没有错误,但是一旦执行!lockdown,我得到一条消息,说它被锁定了,但是如果有人可以帮助的话,人们仍然可以打字

我的代码:

const Discord = require("discord.js");
const ms = require("ms")

module.exports.run = async (client, message, args) => {
    if(!client.lockit) client.lockit = [];
    let time = args.join(' ');
    let validUnlocks = ['relase', 'unlock'];
    if(!time) return message.channel.send('You must set a duration for the lockdown!')

    if(validUnlocks.includes(time)) {
        message.channel.overwritePermissions(message.guild.id, {
            SEND_MESSAGES: false
        }).then(() => {
            message.channel.sendMessage('Lockdown has been lifted!');
            clearTimeout(client.lockit[message.channel.id]);
            delete client.lockit[message.channel.id];
        }).catch(error => {
            console.log(error);
        });
    } else {
        message.channel.overwritePermissions(message.guild.id, {
            SEND_MESSAGES: false
        }).then(() => {
            message.channel.sendMessage(`Channel Locked for ${ms(ms(time), { long:true})}`).then(() => {
                client.lockit[message.channel.id] = setTimeout(() => {
                    message.channel.overwritePermissions(message.guild.id, {
                        SEND_MESSAGES: false
                    }).then(message.channel.sendMessage('Lockdown Lifted')).catch(console.error);
                    delete client.lockit[message.channel.id];
                }, ms(time));
            }).catch(error => {
                console.log(error)
            })
        })
    }
}

module.exports.help = {
    name: "lockdown",
    description: "Lock a channel",
    usage: "lockdown <duration>",
    accessableby: "Moderators",
}

1 个答案:

答案 0 :(得分:0)

似乎您对@everyone角色具有代码更改权限。

如果您还有另一个角色,具有更高的层次结构级别,并且具有权限SEND_MESSAGES,他们仍然可以在该频道中键入。可能是答案,但是由于我不知道您的服务器的结构。我不能肯定地说。