javascript - 如何在 node.js 中使用startsWith?
问题描述
let botmod = staff.get(`${message.author.id}`)
if (botmod.startsWith !== "Bot")
return message.channel.send("Unfortunately, you are a server mod. You can't use bot commands.")
以上是我尝试使用的示例.startsWith()
。但是,我认为我没有正确使用它。
它会触发该消息,即使该消息确实包含Bot
在其中。
控制台中没有记录错误。
解决方案
startsWith是一个函数,您传递要检查的值,它将返回 a boolean
,所以
if (botmod.startsWith("Bot"))
...
}
推荐阅读
- c# - 在编写 DefaultTrackableEventHandler.cs 脚本时,如何修复“成员修饰符“受保护”必须位于成员类型和名称之前
- c - C列表多线程同步
- java - java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler
- python - 如何使用for循环使用python脚本将值1-100插入redis?
- python - 将熊猫数据框的日期与当前日期进行比较
- docker - 如何从 docker 取消设置环境变量?
- docker - 仅在使用 Dockerfile 进行生产时,如何复制文件?
- sqlite - 什么存储选项最适合 2019 年的 phonegap?
- javascript - 多上传进度条
- python - Python:断言不打印错误消息