Discord bot doesn't show up in server members, even though invitation button says it has joined

Question:

I made a bot with discord.py and have already invited it to my own private server. It works on that one without issues and now I wanted to add it to another server on which I have mod permissions. So I send an invitation to the new channel to my bot and clicked the accept button. I got redirected to the chat and the button in the DMs of the Bot show that it has joined the server. However, it does not show up in the members of the server, neither the specific channel I invited it to, nor the complete members list. When I run my py script with the channel guild, it gives me the following error message.

[2022-12-23 04:27:15] [ERROR   ] discord.client: Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:PythonPython38libsite-packagesdiscordclient.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:UserschrisDesktopJap AppJapanese_Vocabulary_Bot.py", line 75, in on_ready
    await tree.sync(guild=discord.Object(id=guild))
  File "C:PythonPython38libsite-packagesdiscordapp_commandstree.py", line 1071, in sync
    data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
  File "C:PythonPython38libsite-packagesdiscordhttp.py", line 738, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

The only solutions to this error message I’ve seen is to give the bot the necessary permissions either with a role or in the creation tab of the bot. I already gave it permissions during creation and I can’t give it a role since I can’t see it on the server (even though it tells me it already joined).

So what can I do? It still works fine with the guild ID of my private server. But when I give it the guild ID of the channel in the other server, it gives me that error. Even though it says it has joined that server.

EDIT: I tried to add the OAuth2 option application.commands and a few others in the "Bot" tab, but I cannot confirm my settings anywhere. The moment I tick one of the boxes and change tabs and go back, all my settings have been reset. I don’t know how to make the changes on the webpage stick. As far as I can tell, the problem is that discord has changed something about the way you authorise bots to do things in a server/channel and because of that I need to go to
https://discord.com/developers/applications/APPLICATION_ID/oauth2/url-generator

and set the appropriate options for my application. But I don’t understand what the url-generator does and how to confirm my choices on the webpage. I selected "bot" and "applications.commands" in the OAuth2 tab under the URL section. That opened a bunch of checkboxes with permissions under which I selected the following

  • selected bot permissions

Now I want to confirm my choices, but i don’t know how.

EDIT 2: I figured out that I’m supposed to choose my bot’s privileges and then use the generated URL to allow it to join a particular server, but no matter which options I pick, the "Generated URL" box only ever says: "Please provide a template uri".

I’m going through the docs from A-Z right now, but I don’t understand why the box doesn’t generate any kind of link. I’m using Brave as a browser so I deactivated shields just in case, but no change.

Asked By: J.Doe

||

Answers:

Ok so the problem was simply that my browser didn’t allow the Generated URL box to be filled. I was using Brave.

I remade the bot in the application page, but this time I used Mozilla instead of Brave. Worked immediately… The steps I followed were simply outlined in the discord.py docs:

Here’s the scopes I selected
In the OAuth2 tab in the URL generator section I selected "bot" and nothing else. Apparently you don’t need to select "applications.commands", but if it’s not working for you, you might need to tick that box as well.

Under "bot permissions" I selected the following options:
enter image description here

And now that I am no longer using Brave, the "Generated URL" box is filled with the join link that you need to paste into the searchbar of your browser.
enter image description here

I made a very minimalistic/small bot so if you want to replicate this, just follow the instructions in the docs. I neither chose to make my bot public nor to give it "OAuth2 Code Grant". I don’t know what it does, but apparently I don’t need those for a private bot on my private server that is only online when I run my py script.
enter image description here

So pro tip: Don’t use Brave when working with the discord application page on which you create the bot/bot user. Even if you disable shields, you might still not see the Generated URL box being filled with the join link your bot needs to join a server of your choosing.

Answered By: J.Doe
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.