Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
SyntaxError: Unexpected token 'const'

how can i solve my error in line 16 witch is syntax error can any one help me to fix it this is 'command handler' for discord js

const { Events } = require("../Validation/Events");
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 (event.name) {
            if(!Events.includes(event.name))
            const L = file.split("/");
            return Table.addRow(`${event.name || "MISSING"}`, `⛔ Event name is either invalid or missing ${L[6] + `/` + L[7]}`);
        }

        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());
}```
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

What is

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

supposed to do ?

You most likely wanted to group those

if(!Events.includes(event.name)) {
    const L = file.split("/");
    return Table.addRow(`${event.name || "MISSING"}`, `⛔ Event name is either invalid or missing ${L[6] + `/` + L[7]}`);
}
about 4 years ago · Juan Pablo Isaza Report

0

You are saying

if(!Events.includes(event.name))
const L = file.split("/");

Which doesn't make sense because const is block scoped. You forgot {}

if (event.name) {
   if(!Events.includes(event.name)) {
       const L = file.split("/");
       return Table.addRow(`${event.name || "MISSING"}`, `⛔ Event name is either invalid or missing ${L[6] + `/` + L[7]}`);
    }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!