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

157
Vistas
Discord.JS data.some is not a function when checking message.content against array

I'm trying to check message.content against a JSON and an API link that is fetched and stored to the const data for a automod bot.

The JSON and API link both contain arrays with 600+ items stored.

The idea is to check against a locally stored JSON, and then an API to prevent links being posted.

The code works fine for 90% of the time, but while testing and sending multiple links in a short space of time, i get this error:

TypeError: data.some is not a function

This is the code:

client.on('messageCreate', async (message) => {
     try {
          const guild = client.guilds.cache.get(message.guildId);
          const member = guild.members.cache.get(message.author.id);
          const modLogs = client.channels.cache.get(modLogsChannelID);
          const response = await fetch(
               definedAPI,
          );
          const data = await response.json();

          if (badLinksJSON.some(letter => message.content.includes(letter))) {
               console.log(`${member.user.tag} used a bad link and has been muted.`)
               member.roles.add(mutedRoleID).catch(err => console.error);
               message.channel.send(`${message.author.toString()} You have been muted for: **Bad Link Usage**`).catch(console.error).then(message.delete()).catch(err => console.error);

          } else if (data.some(word => message.content.includes(word))) {
               console.log(`${member.user.tag} used a bad link and has been muted.`)
               member.roles.add(mutedRoleID).catch(err => console.error);
               message.channel.send(`${message.author.toString()} You have been muted for: **Bad Link Usage**`).catch(console.error).then(message.delete()).catch(err => console.error);
          }  
     } catch (error) {
          message.channel.send('Oops, there was an error fetching the API');
          console.log(error);
     }
}

Note: > Multiple variables are defined in the code file above, I have not included them in the code snippet

The try and catch were added to prevent the bot from crashing if this error occured. I am aware it could be done other ways.

Any help is appreciated, TIA.

about 4 years ago · Santiago Gelvez
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