Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

421
Vistas
Random Meme Command (discord.js v13)

I'm trying to make random meme command that sends meme's from r/reddit, but i have an error

const { MessageEmbed } = require("discord.js");
const fetch = require("node-fetch");

module.exports = {
  name: "meme",
  description: "This command sends you random memes",
  category: "fun",
  example: ["x!meme"],
  callback: async ({ message }) => {
    try {
      const url = await fetch("https://www.reddit.com/r/memes/random/.json");
      const random = await url.json();

      const embed = new MessageEmbed()
        .setTitle(`Random Meme | ${random[0].data.children.data.title}`)
        .setImage(random[0].data.children.data.url)
        .setColor("#FF00A6");
        .setFooter("Prefix x! | Random Meme Generator")

      await message.channel.send({ embeds: [embed] });
    } catch (err) {
      console.log(err);
    }
  },
};

I don't know why but I get this error

On the older version (discord.js v12) it worked normally

TypeError: Cannot read properties of undefined (reading 'title')
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After visiting the link, it seems like random[0].data.children is an array. Get the first element from it:

.setTitle(`Random Meme | ${random[0].data.children[0].data.title}`)

You will need to do the same with the image:

.setImage(random[0].data.children[0].data.url)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda