Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
[EMBED_DESCRIPTION]: MessageEmbed description must be a string

This is my code and im getting this error: RangeError [EMBED_DESCRIPTION]: MessageEmbed description must be a string can can someone help me please? i want to make leaderboard

const { MessageEmbed } = require("discord.js");
const Discord = require('discord.js');
const Database = require("@replit/database");
const db = new Database();

module.exports = {
  name: "Leaderboard",
  aliases: ['leader', 'leaderboard', 'топ', 'Топ'],
  run: async (client, message, args) => {
    const collection = new Collection();

    await Promise.all(
      message.guild.members.cache.map(async (member) => {
        const id = member.id;
        const bal = await db.get(`balance_${id}`);

        console.log(`${member.user.tag} -> ${bal}`);
        return bal !== 0
          ? collection.set(id, {
              id,
              bal,
            })
          : null;
      })
    );

    const data = collection.sort((a, b) => b.bal - a.bal).first(10);

    message.channel.send(
      new MessageEmbed()
        .setTitle(`Leaderboard in ${message.guild.name}`)
        .setDescription(
          data.map((v, i) => {
            return `${i + 1}) ${client.users.cache.get(v.id).tag} => **${v.bal} coins**`;
          })
        )
    );
  },
};```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In setDescription you're calling data.map(...) which returns an array. You can use Array.prototype.join to create a string from the array elements: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join

data.map(...).join('\n')

If your array looked like this ['abc', 'def', 'ghi'] then the output of the join would be a string that looks like this:

abc
def
ghi
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!