How to reverse the order of Discord messages that I get from the "List channel messages" module?"

Hello everyone!

I am working on a scenario Discord “List channel messages” module ==> Discord “Send message to a channel”. i.e. I want to redirect messages from one Discord channel to another.

Everything works fine but the problem is that the Discord “List channel messages” module retrieves messages in a reverse order i.e. from the newest to the oldest messages. But I need to redirect these messages in a normal order from the oldest to the newest messages.

So, what is the way (preferably simple) to reverse the order of messages?

The API does not provide a way to get messages from a channel by age, only by their position relative to a particular message ID. For example, you can ask for X messages before, after, or around a given message ID. So if you know the message ID you want to get the messages before or after, you can do that within a manual API call on the Discord module.

If you’re currently able to get the messages you need but just need to change their order in the array, use {{reverse( )}} function on the array.

1 Like

Firstly, you need to aggregate the bundles into a single array.

Aggregators

Every result (item/record) from iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module.

Reverse

You can then use the built-in function reverse on the array

e.g.:

reverse(1.array)

For more information, see the function documentation in the Help Center.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.