Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!