Alternative syntax for gallery items

I have this code
const imgs = [/* ... */];

const gallery = new MediaGalleryBuilder().addItems(
imgs.map((img) => (item) => item.setURL(img))
);
const imgs = [/* ... */];

const gallery = new MediaGalleryBuilder().addItems(
imgs.map((img) => (item) => item.setURL(img))
);
Can I refactor this code so that I'm not returning a function from .map() to make this code easier to understand?
5 Replies
d.js toolkit
d.js toolkit2w ago
duck
duck2w ago
yes, <MediaGalleryBuilder>.addItems() also accepts a rest param or an array of MediaGalleryItemBuilders as well
d.js docs
d.js docs2w ago
documentation suggestion for @functiondj: :method: MediaGalleryBuilder#addItems() discord.js@14.24.2 Adds items to this media gallery.
functiondj
functiondjOP2w ago
thanks!
d.js toolkit
d.js toolkit2w ago
The thread owner has marked this issue as solved.

Did you find this page helpful?