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

184
Vistas
is there any way to generate invite links of the channels where my discord.js bot is in?

but I have a serious problem that I had a Discord channel with my friend and my Discord.js bot like bellow. But I left the channel and my friend is dead so Im unable to join the sever anymore.

const { Client, Intents } = require('discord.js')
const { prefix, token } = require("./config.json");
const ytdl = require("ytdl-core");

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})
  
client.on('ready', () => {
    console.log(client.user.tag + "I came home!")
})


client.on('message', message => {
    // some code for message commands
   
})


client.login(token);

So I want to ask that is there anyway to make my Discord.js bot to generate an invite link of the sever it is in? Because I dont have any knowledge about Discord.js and it's really rushed so please help me with the code.

Thank you everyone for reading.

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

0

You will have to set that in your client.on('ready') :

client.on("ready", async() => {
    const cache = await client.channels.cache;
    const channels = [...cache.keys()];
    const channel = await client.channels.fetch(channels[channels.length - 1]); // that depends of the differents kinds of channels, if this isnt working, try different indexes
    let invite = await channel.createInvite({
      maxAge: 10 * 60 * 1000,
      maxUses: 10,
    });
    console.log(`discord.gg/${invite.code}`)
});

This will create a new invitation. Since you are not on the server, the bot will not be able to send it to you. console.log(discord.gg/${invite.code}) is here so you can copy and paste it into your browser. Then you will be able to join the server.

Have a good day!

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