我的不和谐机器人即使没有命令也会回答前缀

问题描述

“ / tts”也不起作用,即使在tss渗透的情况下,bot也只写。

const prefix = "!";


bot.on('message',message => {
if (message.author.bot || !message.content.startsWith(prefix)) return;

const args = message.content.slice(prefix.length).split(new RegExp(' ','g'));
const command = args.shift().toLowerCase();

const user = message.author;

  if (command == "stretch" || "sr"){
    message.channel.send(user.username + ' your stretch reminder was 

activated!',tts=true);
        }
  });

解决方法

问题与split在一起
拆分接受正则表达式,但这不是插入标志的正确方法
尝试split(new RegExp(' ','g'))

,

1。机器人即使没有命令也能回答

问题出在command == "stretch" || "sr"。它检查commandstretch还是sr存在。由于“ sr”不是未定义的,因此它始终为真,并且该机器人将用除那两个命令以外的命令进行响应。因此,您可以将代码更改为command == 'stretch' || command = 'sr'

2。 TTS无法正常工作

没问题。这是不和谐的错误,对此一无所获。