If I receive two messages on the same channel, I want to be able to retrieve both of them separately

I pressed the wrong button. I am reposting. Sorry for the long title. I would like to do exactly what the title says. By get I mean I can get it like firstMessage.content or lastMessage.author.id. Please let me know if there is anything I don't understand. (I am using DeepL translation. Let me know if anything is not clear) Node.jsVersion: v20.12.2 code:
import type * as discord from "discord.js";

export function tenbin(client: discord.Client) {
const messages = new Map();
client.on("messageCreate", (message) => {
const detectArray = ["年生きた", "だ"];

const isAllIncluded = detectArray.every((str) =>
message.content.includes(str),
);

if (isAllIncluded) {
// Await !vote messages
const filter = (m: { content: string | string[] }) =>
detectArray.every((str) => m.content.includes(str));
// Errors: ['time'] treats ending because of the time limit as an error
message.channel
.awaitMessages({ filter, max: 2, time: 15_000, errors: ["time"] })
.then((collected) => console.log(collected.size))
.catch((collected) => console.log(`${collected.size}`));
}
});
}
import type * as discord from "discord.js";

export function tenbin(client: discord.Client) {
const messages = new Map();
client.on("messageCreate", (message) => {
const detectArray = ["年生きた", "だ"];

const isAllIncluded = detectArray.every((str) =>
message.content.includes(str),
);

if (isAllIncluded) {
// Await !vote messages
const filter = (m: { content: string | string[] }) =>
detectArray.every((str) => m.content.includes(str));
// Errors: ['time'] treats ending because of the time limit as an error
message.channel
.awaitMessages({ filter, max: 2, time: 15_000, errors: ["time"] })
.then((collected) => console.log(collected.size))
.catch((collected) => console.log(`${collected.size}`));
}
});
}
I got an output that I don't understand:
1
0
1
0
message send:
れいたんは10年生きた鯖民だ
れいたんは20年生きた鯖民だ
れいたんは10年生きた鯖民だ
れいたんは20年生きた鯖民だ
1 Reply
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Want results from more Discord servers?
Add your server