Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

discord.js Send message as code block?

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?

like image 674
Mad_ Questionnaire Avatar asked Oct 24 '25 21:10

Mad_ Questionnaire


1 Answers

Have you tried using this?

var msg = "```Their Title\nBody text blah blah```";

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

like image 92
Siki Avatar answered Oct 27 '25 12:10

Siki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!