I’m working with discord.py version 0.16.12 and trying to create a feature where my bot can join servers programmatically. I want to build a command that takes an invite link and makes the bot join that server automatically.
I tried creating something like this:
@bot.command(pass_context=True)
async def enter_server(ctx, invitation_url):
bot.join_guild(invitation_url)
I also attempted using another approach:
@bot.command()
async def connect_to_server(invite_link):
await bot.use_invite(invite_link)
But when I run the second method, I get this error message:
discord.errors.Forbidden: FORBIDDEN (status code: 403): Bots cannot use this endpoint
Is there any workaround or alternative method to achieve this functionality? I’ve been searching but haven’t found a clear solution yet.
Unfortunately, Discord deliberately removed the ability for bots to join servers through invite links several years ago due to abuse concerns. The error you’re encountering is expected behavior - Discord’s API simply doesn’t allow bots to use invitation endpoints anymore.
The only legitimate way for your bot to join servers now is through manual invitation by server administrators. They need to generate an OAuth2 invite link with the proper permissions and client ID, then manually add your bot to their server.
I ran into this same limitation when building my first bot back in 2019. Initially frustrating, but it makes sense from Discord’s perspective since it prevents spam bots from automatically joining servers without permission. You’ll need to rethink your approach and focus on having users invite your bot manually through the standard OAuth2 flow instead.
This restriction has been in place since around 2017 when Discord tightened their bot policies. What you’re experiencing is completely normal - the 403 Forbidden error is Discord’s way of blocking this functionality entirely. Even if you find older tutorials or code examples showing bots joining via invites, those methods are permanently disabled. The workaround is setting up proper OAuth2 authorization. You need to create an invite URL using Discord’s developer portal with your bot’s client ID and required permissions. Server owners then use this URL to add your bot manually. I’ve maintained several bots over the years and this is the only viable method now. Focus on making your OAuth2 invite process as streamlined as possible for users instead of trying to automate the joining process.
yeah thats not gonna work anymore mate. discord killed that feature ages ago for security reasons. basically bots were spamming servers left and right so they said nope. only way now is oauth2 invites where server owners have to manually add your bot thru the developer portal link.