Discord.js translate bot for discord server

Viewed 149

i wanna make a translate command for my bot but the bug is cannot send an empty message

  if (message.content.startsWith('/trans')) {
    const trans = message.content.slice(6).trim();
    const translated = translate(trans, {to: 'en'});
    message.reply(translated.text);
    } 
  })
1 Answers

You can use a simple condition:

message.reply( (translated.text.length < 1 )?"please insert some text to translation!":translated.text );
Related