2017-04-20 13 views
0

私は現在、ロールプレイバー用の不協和音ボットを書いています。私はそれを教えてくれるときにバーを閉鎖する(つまり、投稿のアクセス権を私だけに制限する)ようにします。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後に何を置くべきですか?

+0

あなたは何をしたいのですか、あなたは何を得ていますか? – abdulbarik

+0

私が言ったように、私はチャットの許可を変更して誰もそれに投稿することができないようにしたい。私はどこから始めるべきか分からないので、何の誤りもありません。 – tomtomy8

+1

あなたは 'channel.sendMessage'を意味しませんか? – Wright

答えて

0

私はドキュメントの中で、postMessageの代わりにmessage.sendMessageを使用しています。また、このメソッドには、 "channel、content、options、callback"というパラメータもあります。あなたがその役割を持つ誰もがメッセージを送信することを許可しないようにchannelRoleのアクセス権を設定しており、このような.overwritePermissionsを使用して試すことができますhttps://discordjs.readthedocs.io/en/latest/docs_client.html

0

詳細はで見つけることができ

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.find('name', '<name of role>'); 

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

あなたは、そのRoleを持つ人々がメッセージを送信できる他のRoleも持っていないことを確認するだけです。

関連する問題