Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

282
Visualizações
TypeError: (intermediate value) is not a function

so I'm currently making a Discord bot using Discord.JS V13.

I keep getting this error when I run the node index.js command

TypeError: (intermediate value) is not a function
    at module.exports (C:\Users\myUser\OneDrive\Desktop\Green Hosting Discord bot\Handlers\Events.js:10:5)

I don't know why it is doing this. The code is:

const { Events } = require("../Validation/EventNames");
const { promisify } = require("util");
const { glob } = require("glob");
const PG = promisify(glob);
const Ascii = require("ascii-table");

module.exports = async (client) => {
    const Table = new Ascii("Events Loaded")

    (await PG(`${process.cwd()}/Events/*/*.js`)).map(async (file)=>{
        const event = require(file);

        if(!Events.includes(event.name) || !event.name) {
            const L = file.split("/");
            await Table.addRow(`${event.name || "MISSING"}`, `⛔ Event name is either invalid or missing: ${L[6] + "/" + L[7]}`)
            return;
        };

        if(event.once){
            client.once(event.name, (...args)=>event.execute(...args, client));
        } else {
            client.on(event.name, (...args)=>event.execute(...args, client));
        };

        await Table.addRow(event.name, "✔ SUCCESSFUL")
    });

    console.log(Table.toString());
};

If you could help me, that would be amazing. Thank you.

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

There is no semicolon after const Table = new Ascii("Events Loaded"). The automatic semicolon insertion will only apply if without the semicolon the code would be invalid if concatenated. However here it the code is valid (but fails at runtime):

const Table = new Ascii("Events Loaded")

(await PG(`${process.cwd()}/Events/*/*.js`)).map(/*...*/)

⬇

const Table = new Ascii("Events Loaded")(await PG(`${process.cwd()}/Events/*/*.js`)).map(/*...*/)

As you can see, this would be a function call on the return value of new Ascii("Events Loaded"). However, that isn't a function and can't be called, hence the error.

The solution is therefore to add the missing semicolon here:

const Table = new Ascii("Events Loaded");
//                                      ^

Or, if you want to write code without semicolons, you instead need to insert a semicolon at the start of lines if they begin with certain characters including (, as is the case here:

;(await PG(`${process.cwd()}/Events/*/*.js`)).map(/*...*/)
about 4 years ago · Santiago Gelvez Relatório

0

Try:

const promise = await PG(`${process.cwd()}/Events/*/*.js`)
promise.map(async (file)=>{
   // code...    
});

Or maybe, It's the semi colomn:

const Table = new Ascii("Events Loaded");
//--------------------------------------^
(await PG(`${process.cwd()}/Events/*/*.js`)).map(async (file)=>{
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda