discord.js Send message as code block? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of discord.js Send message as code block? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m trying to make a bot that will send a message to my channel, but in a code block because using RichEmbed doesn’t work.

I looked some other bots and they send messages like this

```
  Their title
    Body text blah blah
```

I want to send something similar, however when I tried

var msg = ``` 
  Their Title
    Body text blah blah
```;

and

var msg = "```
  Their Title
    Body text blah blah
```";

These don’t work.

const Discord = require("discord.js");
const bot = new Discord.Client();
const TOKEN = "MY_TOKEN_ID";

bot.on("message", function(message) {

    console.log(message.content);

    if ( message.author.equals(bot.user)) 
        return;

    message.channel.send(msg);



});

bot.login(TOKEN);

My code is above, any ideas how to send code blocks?

Answer

Have you tried using this?

var msg = "```Their TitlenBody text blah blah```";

n is a new line, it’s basically pressing ENTER when writing. You can send it as normal text message afterward.

We are here to answer your question about discord.js Send message as code block? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji