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

230
Vistas
Detect when someone use an emoji in discord.js

I made a function in a discord bot that will delete user message, when its lenght is past 100 characters, animated/custom/unicode emojis however bypasses this 100 characters limit (theoretically, 1 emoji is not equal to 1 character, idk how it works) but my bot crash after to many of them. I want to make a function, that will detect these emojis, and if it finds one, just delete this person comment. I was working on something like that.

client.on('messageCreate', message =>{ 
  if(message.content.startsWith(":") && message.content.endsWith(":") || message.content.startsWith("<:") && message.content.endsWith(":>") {
    return;
  }
  else {
  if(!message.content.startsWith(prefix) || message.author.bot || message.member.roles.cache.has('828277437242146816')) return;

If you have any other solution, you can share it in a comment.

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

0

All emojis in Discord start with <: (animated emojis start with <:a) and end with :>. Between these group of characters is the emoji name aswell as it's ID. You can use String.prototype.match() to match regex with a string, thus finding an emoji. You can read more about the method here. Using message.content.startsWith("<:") and message.content.endsWith(":>") isn't reliable as messages don't often start with emojis.

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