How to change the array order? Discord.js

Asked

Viewed 110 times

-1

This is code for logging the channel. Basically what I did was create an array with all the messages and format it so it stays this way: Member#0000: (message). Only when I print it out on the console, or anywhere else, the messages come upside down. For example, the last message said is the first to be shown. I want the last message said to be the last message of the log, how do I do this (reverse the order)?

Código

1 answer

0


Using the function re-verse javascript:

messages
     .array()
     .reverse()
     .map(msg => console.log(`${msg.author.tag}: ${msg.content}`));

Observing: To var arr is not being read anywhere and is within the scope of foreach even not taking anything from him. It is better to declare her out of this scope.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.