message discord.js code example

Example 1: how to send a message discord.js

message.reply("message here");
message.channel.send("message here");

Example 2: send a message using discord.js

message.channel.send("test")

Example 3: discord js message

client.on("message", message => {
    if (message.content.toLowerCase() === 'Hello') {
        message.channel.send("**Hey! What's Up?**")
    }
})
// This Will Print "Hey! What's Up?" When Someone Says "Hello" //

Example 4: discord.js MessageEmbed

//top of file
const Discord = require('discord.js')

//example (inside of a command)

const embed = new Discord.Message.Embed()
embed.setAuthor(`example`)
embed.setTitle(`example`)
embed.setDescription(`example`)

message.channel.send({embed});

//there are obviously some other add-ons, such as AuthorIcon and URL.

Example 5: args slice discord.js

const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase(); 

if (command === "RandomCommand") {
  let firstArgs = args[0]; //first argument
  let secondArgs = args[1]; //second argument
  if (firstArgs && secondArgs) { //check if the args are existing
  	message.channel.send(firstArgs, secondArgs) //send the value of the args
  }
}