簡體   English   中英

鎖定命令 discord.js v12

[英]Lock command discord.js v12

我正在嘗試制作一個鎖定命令,這是我的代碼:

module.exports = {
  name: "lock",
  description: "Lock",
  async run(client, message, args) {
    if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send('You can\'t use that!')
    function lock(message) {
      let channel = message.channel;
      let roles = message.guild.roles;
      let testRole = roles.find('Verified');
      channel.overwritePermissions(
        testRole, {
          'SEND_MESSAGES': false
        },
        'Competitive has Ended'
      )
      lock(message).catch(error => console.log(error));
    }
    message.channel.send('Channel Locked')
  }
}

但是,在運行此代碼時,我沒有收到機器人的響應,也沒有執行該功能。 我也沒有收到任何錯誤。 玩具能幫我嗎? 提前致謝!

您定義了一個函數lock ,但在錯誤的地方調用了它。 您嘗試在函數本身內調用鎖定函數,但這是行不通的。 如果您將代碼更改為以下內容,它應該可以工作:

if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send('You can\'t use that!')
function lock(message) {
  let channel = message.channel;
  let roles = message.guild.roles;
  let testRole = roles.find('Verified');
  channel.overwritePermissions(
    testRole, {
      'SEND_MESSAGES': false
    },
    'Competitive has Ended'
  )
}
lock(message).catch(error => console.log(error));
message.channel.send('Channel Locked')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM