#Split API call results into multiple embeds?

1 messages · Page 1 of 1 (latest)

kindred edge
#

Hello guys!
So i'm pretty new to coding and am trying to create a simple bot that would make an API call and post the result in a discord channel. I managed to get all the info i need but it can't post it because it exceeds characters limit.

Do you have any idea how i could split the results into multiple embeds?

Here's the API i'm making my call to: https://api.howrare.is/v0.1/drops (getting all results for the day)

Here's my code: https://srcshare.io/?id=62921e259ba7e81e5891a380

Thank you so much for your help ❤️

worn ember
#

You can split those data into chunks

kindred edge
#

Im actually posting here cuz i don't know how lol

silent stream
kindred edge
silent stream
#

You can have up to 10 embeds per message I believe

kindred edge
#

Ima try this thanks

#

Alright, i guess the content needs to be cut in chunks and each chunks put in each embed right?

kindred edge
#

Alright so i'm at the same point.. That was basically my question :/

#

im so lost it's killing me

silent stream
#

There’s this util method https://discord.js.org/#/docs/discord.js/stable/class/Util but it seems to be deprecated

#

I can’t help u more till I’m on pc

kindred edge
#

Yeah, i've read about this but it's deprecated. I've looked at multiple ressources online but i cant figure it out :/

kindred edge
#

So i managed to create an embed for each but i still hit the limit of 10 embeds...
Is there a way to group them by 5 in each embed or some like that?

#

finals.forEach((final) => embeds.push(new MessageEmbed().setDescription(`\n**Name:** ${final.name}\n**Time:** ${final.time}\n**Price:** ${final.price}\n**Nft_count:** ${final.nft_count}\n**Extra:** ${final.extra}\n**Twitter:** ${final.twitter}\n**Discord:** ${final.discord}\n**Website:** ${final.website}`)));

interaction.reply({ embeds });```
sick summit
#

well rather than creating an embed for each iteration, you could use <Array>.map to generate a new array of the information to put in a single embed

#

then after map you can use <Array>.join to join the elements of the array into a string to put in the embed description

kindred edge
sick summit
#

well arrays have a couple methods you could use to get sections from the array

toxic agateBOT
#

mdn Array.prototype.slice()
The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

#

mdn Array.prototype.splice()
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. To access part of an array without modifying it, see slice().

sick summit
#

or you could iterate and section it yourself manually

kindred edge
#

Alright... Too complicated for me. I guess i'll just abandon the project..

sick summit
#

up to you ¯_(ツ)_/¯

kindred edge
#

Im not a god damn quitter i've got to figure this shit out lol.
Thanks for the links ser