Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Discord聊天机器人更改频道发布权限_Javascript_Node.js_Discord - Fatal编程技术网

Javascript Discord聊天机器人更改频道发布权限

Javascript Discord聊天机器人更改频道发布权限,javascript,node.js,discord,Javascript,Node.js,Discord,我目前正在为角色扮演酒吧编写一个discord机器人。当我告诉它时,我希望它关闭该栏(即仅限我发布权限) 代码如下: const Discord = require("discord.js"); const bot = new Discord.Client(); bot.on("message", (message) => { switch (message.content) { case "Close down the bar for me":

我目前正在为角色扮演酒吧编写一个discord机器人。当我告诉它时,我希望它关闭该栏(即仅限我发布权限)

代码如下:

const Discord = require("discord.js");
const bot = new Discord.Client();

bot.on("message", (message) => {

    switch (message.content) {
        case "Close down the bar for me":
            if (message.author.discriminator == ) { // this isn't a typo i just haven't put it in for posting
                message.postMessage("*Ushers people out, closes the cabinets, changes sign to closed, checks for stragglers, locks the doors, shuts the metal barriers, gets on motorbike and rides home*");

        }
}

});

bot.login(''); // the token is meant to be here, I'm just not putting it on the internet!
我应该在message.postMessage之后放置什么才能将默认聊天权限更改为禁止发布?

您可以尝试这样使用,它将
频道中
角色的权限配置为不允许任何具有该角色的人发送消息:

function closeDownChannel(message) {
    let channel = message.channel;
    let roles = message.guild.roles; // collection

    // find specific role - enter name of a role you create here
    let testRole = roles.cache.find(r => r.id === 'role_id_here');

    // overwrites 'SEND_MESSAGES' role, only on this specific channel
    channel.overwritePermissions(
        testRole,
        { 'SEND_MESSAGES': false },
        // optional 'reason' for permission overwrite
        'closing up shop'
    )
    // handle responses / errors
    .then(console.log)
    .catch(console.log);
}

你只需确保拥有
角色的人
没有其他
角色
允许他们发送消息。

你到底想做什么,你会遇到什么错误?正如我所说,我希望能够更改聊天的权限,这样就没有人可以在上面发表文章了。我没有任何错误,因为我不知道从哪里开始。你是说
channel.sendMessage