在discord.js中停止循环 [英] Stop loop in discord.js
本文介绍了在discord.js中停止循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助来停止discord.js中的循环。我不知道该怎么做才能停止循环。
I need help to stop a loop in discord.js. I don't know what to do to stop the loop.
let sec = 5;
let timer = setInterval(function() {
if (command = "8") message.channel.send("ddd");
}, sec * 1000);
if (command = "stoploop") clearInterval(timer);
我的问题是未定义 clearInterval
。
推荐答案
在 if(条件)
语句中,您不能使用 =
。
In if (condition)
statements, you can't use =
. This is used to assign a new value to a variable, property or anything else.
等于选择器的是:
-
==
等于。 -
===
等于相同类型。
==
for equal to.===
for equal to of the same type.
1 == '1' // returns true
1 === '1' // returns false
这篇关于在discord.js中停止循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文