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

398
Views
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 answers
Answer question

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 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!