首页 > 解决方案 > discord.js 中的停止循环

问题描述

我需要帮助来停止 discord.js 中的循环。我不知道该怎么做才能停止循环。

let sec = 5;
let timer = setInterval(function() {
  if (command = "8") message.channel.send("ddd");
}, sec * 1000);

if (command = "stoploop") clearInterval(timer);

我的问题是clearInterval没有定义。

标签: discord.js

解决方案


if (condition)语句中,您不能使用=. 这用于为变量、属性或其他任何内容分配新值。

等于选择器是:

  • ==为等于。
  • ===为相同类型的等于。
1 == '1' // returns true
1 === '1' // returns false

推荐阅读