#How do I get all of the guilds created by the OAuth2 user?

35 messages · Page 1 of 1 (latest)

gleaming lotus
#

I have a dashboard where the user logs in via OAuth, but I want to get all of the guilds that the user has created, is it possible to do this on my own server and return the result rather than use the Discord API on the browser client?

frozen lodge
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

gleaming lotus
#

@discordjs/rest

tulip plaza
#

Sure, if you got their OAuth2 token to do it…

gleaming lotus
#

So I'd have to setup a HTTP client for each request I want to make?

#

I looked at mee6 requests, and they make a call to their internal API which returns this:

{
    "guilds": [
        {
            "bot": false,
            "bot_master": true,
            "buffs": [],
            "icon": "795bdeeffb0ea2cf4819f2ef833c4b9f",
            "id": "314079160437964801",
            "name": "Polis",
            "owner": false,
            "permissions": 4398046511103
        },
    ]
}
#

So they must be making the request to get the user's guilds somehow

eager dock
#

yes, u do. users/@me/guilds using the users access token

#

Bearer <accessToken>

gleaming lotus
#

but as u can see, they return the "bot" above too

#

how would they get that info? they must be merging the data from their internal DB

tulip plaza
#

Not from their DB but from the actual bot user probably. Checking if the bot is in that guild

eager dock
#

ye, they probly filter the guilds returned from what i said above and modify that data

gleaming lotus
#

I don't think it would make sense to do that though right? if the bot is in say 19m guilds, they're not going to go through all that data to check if the bot is in a few guilds surely?

#

The best approach imo is to store in DB the guild when guildCreate is fired from bot

#

then remove guild when guildLeave is fired from bot

tulip plaza
candid cape
#

you can't get the guilds created reliably afaik, only guilds owned

gleaming lotus
tulip plaza
gleaming lotus
#

yeah but it would be more efficient going through the DB than make a filtering through the json data right?

tulip plaza
gleaming lotus
#

not a bot, using REST API

tulip plaza
#

Then why did you ask about how MEE6 could add the bot fields on it, if it‘s totally irrelevant for your use-case?

gleaming lotus
#

wtf

#

dw bro ill figure it out myself...

#

I'm not particularly a fan of your attitude

#

It is relevant. I was wondering if there was a REST route the bot could call to get user guilds and see if the bot is in them without having to actually filter through the data myself

#

mee6 has a dashboard interface where they do the exact same thing

#

their bot is managed by their dashboard

#

that is what i am building

tulip plaza
#

So you do have a bot… Mee6 has communication between their bot process and the process the dashboard runs on. So they send the guildIds of the user owned guilds to bot process, that then replies with what guilds of those the bot is in.

gleaming lotus
#

well no not exactly, why bother calling the bot process? it's just more overhead

#

just query your own DB where you're tracking the stored guilds of the bot