Saturday, 13 May 2017

discord.js Can't send a message when the first word of a sentence is specified

I am trying to make a discord bot. I have a done a ping fonction when the bot answers pong. This a properly working. But now i am trying to make a music bot so the pattern is ~play url I'm taking the first word of the command to be sure it's ~play. But my way to analyze the sentence is not correct apparently.

const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
  console.log('I am ready!');
});

client.on('message', message => {
  if (message.content === '~ping') {  
  message.reply('pong');
  }  
 var msg = message.content;
 var play = msg.split(" ", 1);
  if (play === '~play') {
  console.log('jioejfaoi');
}
});


client.login('MzEyOTU2MzAwNzcyNTA3NjU4.C_inyw.cT_DDAoqTcKafl1qY42XJFYNTlo');



via Antoine Bonal

No comments:

Post a Comment