discord.js - 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
没有定义。
解决方案
在if (condition)
语句中,您不能使用=
. 这用于为变量、属性或其他任何内容分配新值。
等于选择器是:
==
为等于。===
为相同类型的等于。
1 == '1' // returns true
1 === '1' // returns false
推荐阅读
- javascript - 为什么添加 console.log 语句会阻止测试超时?
- google-chrome - 在 url 中使用别名时 NTLM 而不是 Kerberos 和 Chrome 版本 69
- html - CSS - 使复选框和长描述内联
- jsf - PrimeFaces 6.1 中rich:extendedDataTable 的替代方案
- c++ - MS Word ShapeNode 坐标无法获取
- javascript - 如何在 React 中创建下拉菜单?
- javascript - React 受控组件与不受控组件的总体定义
- angular - 如何访问在同一个父组件中多次使用的子组件的不同输入的值?
- shell - 在引用另一个时设置环境变量
- android - 如何从 Android 中的 WebView 获取 JSON 响应?