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

231
Visualizações
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 Respostas
Responde à pergunta

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 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