BOT不是悄悄话正确回答
- BOT不是悄悄话正确回答 推荐度:
- 相关推荐
BOT不是悄悄话正确回答
所以,这个代码块是玩家A(挑战者)的游戏发布到玩家B(目标)是一个挑战守则的一部分。机器人发送悄悄话给玩家B告诉他们,他们的挑战,并询问他们是否接受或拒绝的挑战。 下面的代码似乎并没有回应什么玩家B与答复。
if (message.channel.id === '541736552582086656') return target.send("Do you accept the challenge? Please reply with 'accept' or 'deny'.")
.then((newmsg) => {
newmsg.channel.awaitMessages(response => response.content, {
max: 1,
time: 150000,
errors: ['time'],
}).then((collected) => {
if (collected === 'accept') {
newmsg.channel.send("You have ***accepted*** the challenge. Please wait while your battlefield is made...");
} else if (collected === 'deny') {
newmsg.channel.send("You have ***denied*** the challenge.")
}
}).catch(() => {
newmsg.channel.send('Please Accept or Deny the challenge.');
});
});
}
在此之前的代码块,我设置了登录信息到服务器上的一个通道,发送挑战者和目标的挑战信息。机器人成功地接触,他们通过质疑下午目标,但答复的内容(即使有回复时“接受”还是会觉得被拒绝。 感谢您的任何和所有帮助!
回答如下:扩大在@Stock Overflaw的回答,awaitMessages
总是返回获取信息的集合,这意味着collected === 'accepted'
将无法正常工作。你检查,如果一个集合对象相同的字符串。
你需要的是从集合抢第一(和你的情况只)消息,并检查其对字符串的内容。下面你会发现你的.then(...)
声明重写。搏一搏,让我知道结果是什么。
附:您的收藏过滤器将无法正常工作,你可能期望。该过滤器只检查,如果消息将被添加到集合与否。因为你的“过滤器”是response => response.content
,它只会检查response.content
不为空,null
或undefined
.then((collected) => {
// Grabs the first (and only) message from the collection.
const reply = collected.first();
if (reply.content === 'accept'){
reply.channel.send("You have ***accepted*** the challenge. Please wait while your battlefield is made...");
} else if (reply.content === 'deny') {
reply.channel.send("You have ***denied*** the challenge.")
} else {
reply.channel.send("Your response wasn't valid.");
/*
* Code here to handle invalid responses
*/
}
})
最新文章
- php的api接口
- 卷积神经网络中特征图大小计算公式总结
- 软件设计之“信雅达”
- (转载)俞敏洪一分钟励志演讲
- React:Component组件
- 如何解决高并发
- DEV GridView 部分属性
- GridView选中状态
- 最速下降法(梯度下降法)python实现
- 网络Socket编程
- 回溯算法 允许重复选择元素的组合
- TextOut字体设置
- Web兼容性测试的要点
- JMeter BeanShell 应用
- SAR成像系列:【5】合成孔径雷达(SAR)成像算法
- 如何自学Python爬虫,python爬虫快速入门教程
- 损失函数——均方误差(Mean Squared Error,MSE)
- 网页弹出对话框详解
- shiro漏洞原理以及检测key值原理
- linux查看tomcat在,在陌生Linux环境查看Tomcat服务的方法