Coder Social home page Coder Social logo

Comments (3)

d-shaun avatar d-shaun commented on June 7, 2024 1

You could create a new array of objects with both the title and link by looping through the links and accessing the value of names on the same index or vise versa.

const names = ["DuckDuckGo", "Discord", "GitHub"];
const links = [
  "https://duckduckgo.com",
  "https://discord.com",
  "https://github.com",
];

const names_with_links = names.map((name, i) => ({ name, link: links[i] }));
console.log(names_with_links);
// OUTPUT: [{ name: "DuckDuckGo", link: "https://duckduckgo.com" }, ...];

And then modify the function in .formatField appropriately.

const FieldsEmbed = new Pagination.FieldsEmbed()
  .setArray(names_with_links)
  .setChannel(message.channel)
  .formatField("LINK", (elem) => `[CLICK HERE TO ${elem.name}](${elem.link})`); 

from discord-paginationembed.

sawa-ko avatar sawa-ko commented on June 7, 2024

Try to do it this way

const test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
const FieldsEmbed = new Pagination.FieldsEmbed()
  .setArray(test)
  .setAuthorizedUsers([message.author.id])
  .setChannel(message.channel)
  .formatField('Numbers' , n => n)
  .setElementsPerPage(2);

FieldsEmbed.build();

from discord-paginationembed.

andrebrito16 avatar andrebrito16 commented on June 7, 2024

Thank you! Worked fine!

Can you help me with another thing?

I Have an API that return two different arrays like links[] and names[]. I`d like to know if it is possible build an embed to show like CLICK HERE TO 1, CLICK HERE TO 2...

If yes, how can I do this.

This image shows how can I need. But instead "Test" I need the names that are saved on other array.

image

from discord-paginationembed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.