javascript - 有没有办法否定 message.content?
问题描述
如果它不以“播放!”开头,我正在尝试让我的机器人从一个特定频道中删除所有消息。
我试过了(message.channel === (channel number) && !message.content.('play!'))
。这似乎不起作用。
bot.on('message', message=>{
//delete all in channel if not beginning with play! starts here
if (message.channel === (the channel) && !message.content.('play!')) {
message.delete(50);
}
// and ends here
})
我希望它能删除所有不以 play 开头的消息!并且在频道中。
解决方案
你应该使用
if (message.channel === (the channel) && !message.content.startsWith('play!')) {
return message.delete(50);
}
因此!message.content.startsWith('play!')
,return message.delete(50);
删除该消息并停止对该消息执行任何其他操作。
推荐阅读
- elasticsearch - Elasticsearch '[bool] 无法解析字段 [filter]' 异常
- c - 尝试执行 ioctl 时出现一般保护错误
- c - 两个给定整数的不同位
- kernel - 内核中 MMU 上下文中的 PMM 竞技场是什么(锆石/紫红色)
- ios - 获取周开始日不同于星期一的周数 - IOS
- python - Python pp 一个 Json 配置文件
- javascript - 从 react-redux 中的元素中删除事件监听器的问题
- gem5 - gem5 中 regStats() 函数的输出存储在哪里?
- xpath - 使用 wso2 esb 更改原始有效负载
- logstash - docker 中的 logstash 错误“无法执行操作”