• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

175
Vistas
How to create a embed for a API response for a Discord Bot

I have added a API response to my Discord Bot and want to know how to format this API response into a embed to make it look nice when it gets sent in Discord

Here is my code:

const ifliveService = require("../utils/InfiniteFlightLive")
const ifl = new ifliveService()

module.exports = {
    category: "Userstats",
    description: "Fetches the users states from Discourse.",
    expectedArgs: '<ifc username>',
    minArgs: 1,
    maxArgs: 1,
    callback: async ({channel, args}) => {
        const username = args[0]
        
        const userstats = await ifl.getUserStats(username)
        if(!userstats || userstats.result == []) return "Invalid user"
        return JSON.stringify(userstats.result[0], null, '\t')
         }
     }

I want to return that base reply into a embed how would that be possible? Please note I am a bit of a beginner with all of this so I apologize if it is a quick and easy solution.

about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can create an embed like this:

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

const embed = new MessageEmbed()
    .setTitle("Your title here")
    .setDescription("Your description here")
    .addField("Field name", "Field value");

// Using Discord.js v13
message.channel.send({ embeds: [ embed ] });

Add as many fields as you like using addField(). You can learn more about embeds in the official documentation.

about 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda