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

时间:2020-08-16 04:42:21

标签: node.js discord bots discord.js

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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

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

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

2。 TTS无法正常工作

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

相关问题