discord.js say command code example

Example 1: Bot say command discord.js

client.on('message', message => {
    if (message.content.startsWith(prefix + 'say')) { // CHANGE ONLY IF EXPERT //
        if (message.author.bot) return;
        const SayMessage = message.content.slice(6).trim(); // CONNECTED WITH prefix + "say" //
        message.channel.send(SayMessage)
        message.channel.send("Text By " + ` **${message.author}**`)
    }
});

Example 2: discord say command

client.on('message', message => {
    if (message.content.startsWith(prefix + 'say')) {
        if (message.author.bot) return;
        const SayMessage = message.content.slice(4).trim();
        message.channel.send("**" + SayMessage + "**")
        message.channel.send("- " + `**${message.author}**`)
    }
});

Example 3: discord js ping command

// If the command sent in the chat is "ping"
if(cmd === `${prefix}ping `) {
  
  // It sends the user "Pinging"
        message.channel.send("Pinging...").then(m =>{
          // The math thingy to calculate the user's ping
            var ping = m.createdTimestamp - message.createdTimestamp;

          // Basic embed
            var embed = new Discord.MessageEmbed()
            .setAuthor(`Your ping is ${ping}`)
            .setColor("Your Color")
            
            // Then It Edits the message with the ping variable embed that you created
            m.edit(embed)
        });
    }

Example 4: Bots latency discord js

var yourping = new Date().getTime() - message.createdTimestamp
var botping = Math.round(bot.ws.ping)

message.channel.send(`Your ping: ${yourping} \nBots ping: ${botping}`)