Answer the question
In order to leave comments, you need to log in
How to get all messages from a discord channel?
I need to get all the messages that are on the channel when requesting a discord bot from my site.
Those. we send a request to my server, on the server the discord bot is already connected to the discord server (there is a server id, a channel id), then my server should return an array with all messages to me.
No matter how much I google, I can’t find it, for documentation my English is really bad
Answer the question
In order to leave comments, you need to log in
use the .fetch() method :
message.channel.messages.fetch({
limit: 100 // количество сообщений
}).then(async messages => {
let finalArray = [];
const putInArray = async (data) => finalArray.push(data);
for (const message of messages.array().reverse()) await putInArray(`${message.content}`);
console.log(finalArray); // ['value1', 'value2', 'valueN']
});
limit
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question