Search code examples
javascriptdiscorddiscord.jsbots

Discord.Js Bot to create invites for users


I need to figure out how to create an invite link for users so that they can track invites. Currently I have this, however this created the invite for the Bot.

const channel = client.channels.cache.find(channel => channel.id === config.server.channelId)
let invite = channel.createInvite({maxAge: 0, maxUses: 0});

Solution

  • Specifically bots cannot create invites for users because each user (including bots) has their very own authorization token, so the only workaround here is by having a user token and calling an endpoint to create an invite, but sharing user tokens isn't very reliable and safe way, and this can be probably called for selfbotting (calling an endpoint with a user token directly, aka not in any of the apps).