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

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

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