[英]Listen for messages or embeds send from my Discord.js bot
I'm trying to add a listener for whenever my discord bot sends an embed with a specific title, however I'm not sure how to collect or listen for that event.每当我的 discord 机器人发送带有特定标题的嵌入时,我都会尝试添加一个侦听器,但是我不确定如何收集或侦听该事件。
I'd like to listen for when my discord bot sends an embed with a title of 'Success'.我想听听我的 discord 机器人何时发送标题为“成功”的嵌入。 Is there a way to listen for embeds sent from my discord bot?
有没有办法收听从我的 discord 机器人发送的嵌入?
It would also work if I could listen for when my discord bot sends a plain text message to a channel, just need a way to listen and do something after it collects that message.如果我可以收听我的 discord 机器人何时向频道发送纯文本消息,它也会起作用,只需要一种方法来收听并在它收集该消息后做某事。
As per the docs , awaitMessages
is a type of MessageCollector
根据文档,
awaitMessages
是MessageCollector
的一种
interaction.channel.awaitMessages({ max: 1, time: 30000, errors: ['time'] })
.then(collected => {
if (collected.hasOwnProperty('title')) {
if (collected.title === 'Success!') interaction.followUp('Detected.')
};
})
.catch(collected => {
interaction.followUp('No messages collected in the time limit.');
});
Since the embed will have property title, check for that property then if the title matches return success.由于嵌入将具有属性标题,请检查该属性,然后如果标题匹配则返回成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.