if (message.content.toLowerCase().startsWith(prefix + `shout`)) {
  if (!message.member.roles.some(r => ["shout perms"].includes(r.name)))
    return message.reply("Sorry, you don't have permissions to use this!");

  if (!args) {
    return;
    message.reply('Please specify a message to shout.')
  }
  const shoutMSG = args.join(" ");

  roblox.shout(groupId, shoutMSG)
    .then(function() {
      console.log(`Shouted ${shoutMSG}`);

    })
  message.channel.sendMessage(`Shouted ${shoutMSG}`)
    .catch(function(error) {
      console.log(`Shout error: ${error}`)
    });
}


上面是使用命令时将向Roblox发送喊叫的代码,但是,它还会喊叫前缀和命令,如下所示。如何解决此问题,使其仅喊出消息而不是前缀和Command?

javascript - “喊”时如何删除部分命令?-LMLPHP

最佳答案

您只需要剪掉前7个字符。 1作为前缀。 5个用于呼喊,另外1个用于空间



var shoutMSG = '!shout Please mark this as correct'
console.log(shoutMSG)
shoutMSG = shoutMSG.substr(7)
console.log(shoutMSG)

关于javascript - “喊”时如何删除部分命令?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53237044/

10-11 23:35