JumpaholicFrog
JumpaholicFrog

Reputation: 120

How do I get all the emotes from an array into an embed? - Discord.js

I have an array of emote IDs, and I want to add a field to an embed which contains all the emotes, but I don´t know how can I do it dinamically, because making a loop will create one field per emote.

Upvotes: 0

Views: 119

Answers (1)

Elitezen
Elitezen

Reputation: 6710

You can create a string of all the id's concatenated through a loop, then just use said string.

However you will also need the emote's name aswell to be able to display the emote.

const ids = ['id1', 'id2', 'id3'];
const names = ['name1', 'name2', 'name3'];

let result = '';
for (let i of ids) {
   result += `<:${names[i]}:${ids[i]}> `;
}

Upvotes: 1

Related Questions