如何在用户说出句子中的单词时发送消息

How to send a message when user says word in a sentence

我希望 sans 保持独立,使用这里的当前代码,无论在哪里 sans,它都会激活。例如:usansu,我不希望它起作用,我希望它像 ex:u sans u 一样只在分开时才起作用。我有在其中使用 "sans" 的命令,这妨碍了它。

一种方法是获取消息并将其拆分为单词。然后你可以检查数组是否包含单词 "sans" 而没有任何额外的字符。

示例代码:

bot.on ('message', function (message){
  const words = message.content.split(' ');

  if(words.includes('sans'))
  {
    message.channel.send("<:download:519723756403425294>");
  }
});