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

126
Visualizações
Discord.js 13 interaction check if interaction creator is in the guild

I recently noticed that interactions can still be made even if a user is not in a guild this is the case in for example the server preview mode

This is causing a few issues for me

does anyone know if there is a convinient way to detect if the user who created the interaction is a guild member? Or could I block all interactions from non guild members ?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

you can search user in the guild and return if it's null.

var user = guild.users.cache.find(user => user.id === 'USER-ID')
if(!user) return
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use Guild.members.cache.some to determine if the user exists.

const exists = interaction.guild.members.cache.some(x => x.id == interaction.user.id)
about 4 years ago · Juan Pablo Isaza Relatório

0

You can try the following piece of code:

const user_exists = (<interaction>.guild.users.cache.find(user => user.id === <interaction>.user.id)) ? true : false

This will return true if the user exists and false if not, so you can run a check:

if(!user_exists) // Tell the person they cannot run the command
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