Javascript 随机引用命令重新建模

Javascript 随机引用命令重新建模,javascript,discord,discord.js,Javascript,Discord,Discord.js,我对JS还比较陌生,我发现了一个Discord机器人的这段代码,我想知道当有人输入时我怎么能做到这一点!quote,响应不会标记用户,并且需要在用户的命令中键入额外的文本。谢谢 if (command == "quote") { if (args[1] != null) message.reply(quote[Math.floor(Math.random() * quote.length).toString(16)]); // if args[1], post random answe

我对JS还比较陌生,我发现了一个Discord机器人的这段代码,我想知道当有人输入时我怎么能做到这一点!quote,响应不会标记用户,并且需要在用户的命令中键入额外的文本。谢谢

if (command == "quote") { 
    if (args[1] != null) message.reply(quote[Math.floor(Math.random() * quote.length).toString(16)]); // if args[1], post random answer
    else message.channel.send("!quote <your text here>"); 
}
if(command==“quote”){
if(args[1]!=null)message.reply(quote[Math.floor(Math.random()*quote.length.toString(16)];//如果args[1],发布随机答案
else message.channel.send(“!quote”);
}
在同一频道发送带有提及标签的消息。如果你不想要提及标签,你必须在同一频道发送消息,你可以用

您的代码应该如下所示:

if (command == "quote") { 
  if (args[1] != null) message.channel.send(quote[Math.floor(Math.random() * quote.length).toString(16)]); // if args[1], post random answer
  else message.channel.send("!quote <your text here>"); 
}

抱歉,您发布的代码似乎与您的问题无关。你在说什么用户?什么命令?我猜
reply
回复用户,然后
channel.send
向频道发送消息<代码>我对JS相当陌生。。。然后在提问之前先学习。谢谢!是否在键入命令时,不必添加任何其他文本?现在你必须做!在这里引用一些文字“对不起,这太麻烦了。”
if (command == "quote") message.channel.send(quote[Math.floor(Math.random() * quote.length).toString(16)]);