【发布时间】:2019-12-28 01:20:17
【问题描述】:
我一直在尝试获取一个频道在另一个频道中写入命令的最后一条消息。
我想做这样的事情:
频道 1 :(我写)“获取频道 2 的最后一条消息 通道 2:最后一条消息是 ("Hello"); 频道 1:我收到频道 2 的最后一条消息说,频道 2 的最后一条消息是。 “你好”。
我的代码是这样的,但不起作用。
if (message.channel.id === '613573853565681671') {
message.channel.fetchMessages().then(collected => {
const filtered = collected.filter(message => message.author.bot);
const lastMessages = filtered.first(1); //Get the last message of this channel.
const TextMessages = `${lastMessages[0].content}`;
console.log(TextMessages + " is the last message of aviso jobs")
if (TextMessages === "look") { //If the last message of this channel is look then go to the other channel
if (message.channel.id === '613553889433747477') {
message.channel.fetchMessages().then(collected => {
const filtered = collected.filter(message => message.author.bot);
const lastMessages2 = filtered.first(1); //Get the last message of this other channel.
const TextMessages2 = `${lastMessages2[0].content}`;
console.log(TextMessages2 + " is the last message of bot")
});
}
}
});
}
【问题讨论】:
标签: javascript node.js discord.js