Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
I am trying to code a discord bot that shows the status of my minecraft server but The bot isn't responding to the command not even with an error
const {Client, RichEmbed, Intents, MessageEmbed } = require('discord.js');

 
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
 
 
const token = 'token is a secret';
 
const PREFIX = '!';
 
bot.on('ready', () =>{
    console.log('Bot has come online.');
});
 
bot.on('messageCreate', message =>{
 
    
    let args = message.content.substring(PREFIX.length).split(' ')
 
    switch(args[0]){
        case 'mc':
            ping = require('minecraft-server-util')
 
 
            ping = ('ip', port, (error, reponse) =>{
                if(error) throw error
                const Embed = new RichEmbed()
                .setTitle('Server Status')
                .addField('Server IP', reponse.host)
                .addField('Server Version', reponse.version)
                .addField('Online Players', reponse.onlinePlayers)
                .addField('Max Players', reponse.maxPlayers)
                
                message.reply({ embeds: [Embed] });
            })
        break
 
    }
 
    })
 
bot.login(token);

Niether is it showing any error. Its just not responding when the command is being issued. Please tell whats wrong with my code.. and please tell how I can correct it. in the line, "bot.on('messageCreate', message =>{..." if i am replacing 'messageCreate' with 'message', the bot is responding on issuing the command, but with an error message saying ' (node:25372) DeprecationWarning: The message event is deprecated. Use messageCreate instead'. Please help me :(

Some replies to this question suggested me to replace the line " ping = ('ip', port, (error, reponse) =>{" with "ping('ip', port, error, response) =>{" but then it gives the error ping is not a function. On some suggestions i realised that "RichEmbed()" was removed in discord v12, so i tried replacing the line const Embed = new RichEmbed() with const Embed = new MessageEmbed() but unfortunately that also did not help. Yet the bot did not respond when the command was issued. The thing is, it also does not show any error message, so i am not able to catch where i have gone wrong.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try removing this line

            ping = ('ip', port, (error, reponse) =>{

and replacing it with

            ping('ip', port, (error, reponse) =>{

The first one is setting a variable ping to be two strings 'ip' and port and a third one who is a function (error,response) =>{}, the second one is using the ping function to actually do something on your code

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda