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

400
Vistas
How to use syntax highlighting for code Blocks for Bot in discord.js (v13)?

I am trying to make a terminal accessible in the discord using the bot. The code for this command is :

const { Client, Message, MessageEmbed } = require("discord.js");
const child = require("child_process");

module.exports = {
  name: "terminal",
  /**
   * @param {Client} client
   * @param {Message} message
   * @param {String[]} args
   */
  run: async (client, message, args) => {
    if (message.author.id !== "") return;

    const command = args.join(" ");

    const errorCommand = new MessageEmbed();

    errorCommand
      .setColor("RED")
      .setDescription("Please specify a command to execute");

    if (!command) return message.reply({ embeds: [errorCommand] });

    child.exec(command, (err, res) => {
      if (err) return console.log(err);
      message.channel.send(` \`\`\`${res.slice(0, 2000)}\`\`\` `, {
        code: "js",
      });
    });
  },
};

When i run the command the syntax highlighting isn't displayed in the code Block. I have attached a picture of what i meant.

Image 1

Image 2

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

0

I found the answer. Sorry for the inconvenient post, In case someone needs the answer, it is :

const { Client, Message, MessageEmbed } = require("discord.js");
const child = require("child_process");

module.exports = {
  name: "terminal",
  /**
   * @param {Client} client
   * @param {Message} message
   * @param {String[]} args
   */
  run: async (client, message, args) => {
    if (message.author.id !== "") return;

    const command = args.join(" ");

    const errorCommand = new MessageEmbed();

    errorCommand
      .setColor("RED")
      .setDescription("Please specify a command to execute");

    if (!command) return message.reply({ embeds: [errorCommand] });

    child.exec(command, (err, res) => {
      if (err) return console.log(err);
      const jsString = "const value = true;";

      message.channel.send(` \`\`\`js\n${res.slice(0, 2000)}\`\`\` `);
    });
  },
};

If u want to use another language syntax highlighting u can just replace js of here message.channel.send(` \`\`\`js\n${res.slice(0, 2000)}\`\`\` `); with your preference.

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