How to code that bot will make a temp instant invite?

I’m trying to make that my bot will create a temp instant invite for a guild that it’s currently in. Is it possible? (This bot will be public, so it will be in a lot of guilds)
If so, I’m asking for help <3
(Sorry, if this is easy to code. I’m still learning js ;D)


You can use GuildChannel.createInvite(). Here’s an example:

// message is the message that triggered the command
// the channel of the invite will be the channel where the message has been sent

async function replyWithInvite(message) {
  let invite = await
    maxAge: 10 * 60 * 1000, // maximum time for the invite, in milliseconds
    maxUses: 1 // maximum times it can be used
  `Requested with command by ${}`

  message.reply(invite ? `Here's your invite: ${invite}` : "There has been an error during the creation of the invite.");

You can change the channel by maybe adding an argument. Please note that this will work only if the bot has the permission to create invites.

Leave a Reply

Your email address will not be published. Required fields are marked *