Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord OAuth2 how to check if a bot is in (joined) a guild

I'm using Discord OAuth2 for my discord bot dashboard. I retrieve the user's servers by the link https://discord.com/api/users/@me/guilds. I want to prompt the user to add my bot to his guild or go directly to the dashboard if the bot is already in the user's guild. But how do I know if the bot is already in a guild? I didn't find any API that does this.

like image 231
Gabor Szita Avatar asked Aug 13 '20 02:08

Gabor Szita


People also ask

How do I find my Discord bot Guild ID?

Find your Guild ID (Server ID)In Discord, open your User Settings by clicking the Settings Cog next to your user name on the bottom. Go to Appearance and enable Developer Mode under the Advanced section, then close User Settings. Open your Discord server, right-click on the server name, then select Copy ID.

How do I use OAuth2 with Discord?

Getting an OAuth2 URLOpen your Discord applications open in new window, create or select an application, and head over to the "OAuth2" page. Once you've added your redirect URL, you will want to generate an OAuth2 URL. Lower down on the page, you can conveniently find an OAuth2 URL Generator provided by Discord.

What is Guild in Discord bot?

Guilds in Discord represent an isolated collection of users and channels, and are often referred to as "servers" in the UI.

How do I join a guild in Discord?

In order to join the Official Discord server, you will need to go to your profile settings and then scroll down. You will see an option that says "Add Discord".


1 Answers

It's an API request per guild, but you could use get guild member with your own bot's ID; if you get a 4xx then your bot isn't present in the guild.

like image 186
Kae Avatar answered Oct 08 '22 06:10

Kae