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

126
Vistas
How do I invite someone to a guild in discord.js?

I'm trying to get my discord bot to message a user with a link to join the guild, but I'm having trouble with who to send it to. Since they're not in the guild you can't message them.

if (!args[0]) return message.reply("Who would you like to invite? For example: funny#6942");
    message.channel.createInvite({
            unique: true,
            maxUses: 1,
            maxAge: 8 * 60 * 1000
        })
        .then(invite => {
            var invited = args[0];
            message.invited.send("https://discord.gg/" + invite.code);
            //dm person with the invite code
        });

I'm still somewhat new to Discord's JavaScript API.

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

0

You can look for that user in all cached users as in

client.users.cache.find((x) => {
 x.tag == `${args[0]}` 
}).send("https://discord.gg/" + invite.code); // This would return a GuildMember object and send the code to that person 

There could be instances where the user is uncached, in those cases it's best to ask for an Id to the user and use <Client>#user#fetch() on them although if your bot is small there's no need to worry! 😄

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