5

Note: I'm using discord.py 0.16.12

I am wondering if there's any way to have a bot join a server within the code. Like there's a command that would be like:

@client.command(pass_context=True)
async def join(ctx, invite):
    client.join(invite)

I've already tried

@client.command()
async def joinserver(mahlink):
    await client.accept_invite(mahlink)

It dosen't work. This is the only thing I could find on google about this

Also, running the accept_invite gives the following:

discord.errors.Forbidden: FORBIDDEN (status code: 403): Bots cannot use this endpoint

Primusa
  • 13,136
  • 3
  • 33
  • 53
Coll y
  • 83
  • 1
  • 3
  • 11

2 Answers2

6

Bots cannot accept invites or join servers/guilds any other way than being manually invited. A user with manager server permissions must authorize the bot and the permissions said bot will be granted upon joining.

You can generate an invite link here

Anu6is
  • 2,137
  • 2
  • 7
  • 17
  • So you can't use some HTTP reroute or anything like that? – Coll y Apr 07 '19 at 14:54
  • No. Because this would allow bots to "randomly" join guilds. So long as the bot has access to an invite link it would be able to accept and get into any guild. Even with basic read message permissions this means that all conversation within that guild could now be logged unknowingly. For a bot to enter a guild, there needs to be explicit permission granted. – Anu6is Apr 07 '19 at 15:45
0

Well, nice try but if this command was avaible for bots I would add my bot to even biggest server of discord. You have to use user token for the token.