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

146
Visualizações
How to make bot grab perma server invite link

I'm working on a bot project that has invite feature, currently I'm having trouble with this command that allow bot to grab server perma invite link (that made by owner/admin) and send the invite link into channel where the command is executed or send the link into user dm after they do the command

Here's my code that I used

and here's the result I got https://i.stack.imgur.com/AkoV8.png

const db = require('quick.db');

module.exports = {
    config: {
        name: "addpermaserverinvite",
        category: "misc",
        description: "Get the permanent invite link of your server!",
        accessableby: ["moderators", "admins", "owner"],
        usage: "p!addpermaserverinvite",
        aliases: ["permaserverinvite"],
    }}[enter image description here][1]

    module.exports.run = async (bot, message, args) => {
        let invite = new MessageEmbed()
            .setColor('ORANGE')
            .setTitle('Here is your permanent invite link!')
            .setDescription(`${message.guild.name}'s permanent invite link is: ${message.guild.invite}`)
            .setFooter('PhoeniX Bot Invite Link')
            .setTimestamp()
        message.channel.send(invite)
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Firstly, you can filter invites with option maxAge which is time expiration option and maxUses as how many uses should be. If you want to filter it by infinite expiration time, you can filter it as maxAge: 0.

For fetching invites, you should have "MANAGE_SERVERS" at least.


    let invites = await message.guild.invites.fetch()
    let infiniteInvite = invites.filter(invite => invite.maxAge === 0 && invite.maxUses === 0).first()
    if(infiniteInvite){
        message.channel.send({embeds: [new MessageEmbed().setDescription(`Your invite link for server **${message.guild.name}**: [Go!](https://discord.gg/${infiniteInvite.code})`)]})
    }

example of getting infinite invite on server

about 4 years ago · Juan Pablo Isaza Relatório

0

Assuming that there is only 1 invite created by the owner, you can use the below code. If there is more than one, this will not work

...
module.exports.run = async (bot, message, args) => {
    const owwerId = message.guild.ownerId
    const invite = await message.guild.invites.fetch().then(invites => invites.find(inv => inv.inviterId === owwerId))
    const inviteEmbed = new MessageEmbed()
        .setColor('ORANGE')
        .setTitle('Here is your permanent invite link!')
        .setDescription(`${message.guild.name}'s permanent invite link is: https://discord.gg/invite/${invite.code}`)
        .setFooter('PhoeniX Bot Invite Link')
        .setTimestamp()

// if using discord v12
    message.channel.send(inviteEmbed)

    // to DM it
    message.author.send(inviteEmbed)

// if using discord v13
    message.channel.send({
        embeds: [inviteEmbed]
    })

    // to DM it
    message.author.send({
        embeds: [inviteEmbed]
    })
}
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