Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

66
Vistas
res.join is not a function

I've been getting this error while trying to code a discord bot in discord.js. The Bot is being used to check for the status of a discord server.

Error:

D:\MinecraftBot\commands\mcserver.js:13
        .then((res) => res.join())
                           ^

TypeError: res.join is not a function
    at D:\MinecraftBot\commands\mcserver.js:13:28

Code In Question:

module.exports = {
    name: "mcserver",
    description: "Get info about a Minecraft Server",
    usage: "mcserver <ip>",
    run: async (client, message, args) => {

        let ip = args[0];

        fetch("https://api.mcsrvstat.us/2/"+args[0])
        .then((res) => res.join()) // <-------- This Line Is Producing The Error
        .then((body) => {
            if(body.online === false) {
                let oneembed = new discord.MessageEmbed()
                .setColor('RANDOM')
                .setAuthor("MC SERVER", message.guild.iconURL ({ dynamic: true }))
                .addField("Status","<a:Offline:766303914654957610>")
                .setTimestamp();
                message.channel.send(oneembed)
            }
            else {
                let embed = new discord.MessageEmbed()
                .setColor('RANDOM')
                .setThumbnail(`https://mc-api.net/v3/server/favicon/${args[0]}`)
                .setAuthor("Mc Server", message.guild.iconURL({ dynamic: true }))
                .addField("Status", "<a:Online:766303827850690600>")
                .addField("IP", body.ip)
                .addField("Hostname", body.hostname)
                .addField("Players", `${body.players.online}/${body.players.max}`)
                .addField("Software", body.software)
                .addField("Version", body.version)
                .addField("Motd", `${body.motd.clean[0]}\n${body.motd.clean[1]}`)
                .setTimestamp()
                .setImage(`http://status.mclive.eu/${args[0]}/${args[0]}/25565/banner.png`)
                message.channel.send(embed)
            }
        })

    }
}

The Data It's Requesting Is Here: https://api.mcsrvstat.us/2/hypixel.net

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos