discord-api-docs icon indicating copy to clipboard operation
discord-api-docs copied to clipboard

Discrepancy between dev portal and application directory for bot's installed server count

Open AlecM33 opened this issue 11 months ago • 11 comments

Description

See the thread in discord's dev support server. Else, read below: https://discord.com/channels/613425648685547541/1318784803289563166

I noticed that my bot has a strange discrepancy in stated values of how many servers have installed the app. The dev portal states around 170 servers:

Screenshot_20241219-144414

However, viewing my app in the public app directory displays a value that is consistently 40-50 servers higher:

Screenshot_20241219-144539

I was advised in the dev support server thread to see what the GET /applications/{application-id} endpoint returns for the app, and the answer is the dev portal value of around 170 servers. At that point I was advised to open an issue here - I am uncertain how the app directory site is deriving 215 servers or so.

For reference, my applications ID is 777314683333771285.

Steps to Reproduce

  1. Retrieve application ID 777314683333771285 via discord's API. Note the approximate installed server count in the response.
  2. View the same app in the app directory site. Note the significant difference in value for the number of servers that have installed the bot.

Expected Behavior

The values eventually display close to the same value

Current Behavior

The values continue to disagree. I know caching or something may be in effect, but interestingly the app directory value is much higher, and the dev portal value, which is stated to update daily, remains much lower.

Screenshots/Videos

No response

Client and System Information

Viewing on Google Pixel 6a running Chrome

AlecM33 avatar Dec 19 '24 19:12 AlecM33

I am experiencing this issue for an HTTP interaction-based application as well.

curl "https://discord.com/api/v10/applications/@me" \
  -H "Authorization: Bot $DISCORD_TOKEN" | jq ".approximate_guild_count"

Output: 0

curl "https://discord.com/api/v10/application-directory-static/applications/$APP_ID" | jq .directory_entry.guild_count

Output: 252

thomasgtaylor avatar Dec 29 '24 21:12 thomasgtaylor

the guild_count returned in the discovery endpoint is a value that is updated as part of a task that runs every 24 hours. the approximate_guild_count value returned as part of the /applications... endpoints is computed on request but then cached for 24 hours. as far as i can tell any discrepency between the two is simply due to drift between the two cached values. so if one is higher than the other im pretty confident that its due to an actual change in the number of guilds

@thomasgtaylor i can check yours as well if you like but i'll need the application id. that being said what i mentioned above is likely true of yours as well. as far as i can tell both numbers were accurate at the time they were computed, but were simply computed at different times within the past 24 hours.

foxfirecodes avatar Jun 12 '25 23:06 foxfirecodes

Is it possible that one includes applications.commands guild installs and one only includes bot installs?

advaith1 avatar Jun 12 '25 23:06 advaith1

@foxfirecodes the issue described by @thomasgtaylor reads as different from mine. You're likely correct about his discrepancy due to the 24 hour delay, but I am concerned with the server counts returned from the API vs. the server count displayed in the app directory. The latter is unknown to me, as in I don't understand how it's calculated. It isn't returned in the API response. FYI I got the below reply in the original discord thread, and it is similar to what @advaith1 offers here I think. Something like that makes more sense as an explanation for my discrepancy, since it stays consistent across 24 hour periods where my bot is only added to 1 or 2 more servers.

Screenshot_20250612-190845.png

AlecM33 avatar Jun 12 '25 23:06 AlecM33

To me this is an issue of two different values with two different underlying calculations being presented as the same thing. That was the source of my confusion

AlecM33 avatar Jun 12 '25 23:06 AlecM33

I can add more detail on my discrepancy. At the time, I didn't have the bot scope added only the applications.commands: ie. users could only install the application to servers and users directly. I used the HTTP interaction gateway and the only server count gauge for me was the static endpoint. The other remained at 0 and did not start increasing until I added the bot scope.

I do not think there was a 24 hour delay in this case as it was like this for a few weeks. Even to this day (after adding the bot scope), there still a 300 or so difference between the two numbers.

Application id: 1016239729030725693

thomasgtaylor avatar Jun 12 '25 23:06 thomasgtaylor

Thanks for jumping in to help @foxfirecodes 😄

thomasgtaylor avatar Jun 12 '25 23:06 thomasgtaylor

ah yknow what you're all absolutely right. the approximate_guild_count is computed based on the number of guilds that the bot user is apart of. the table we're using for approximate_user_install_count and approximate_user_authorization_count has a guild_count col that uses the total number of guild authorizations, just like the app directory. so i will discuss with the team about migrating approximate_guild_count to use this other col instead of counting guilds the bot user is apart of. i will return when i have an update!

foxfirecodes avatar Jun 12 '25 23:06 foxfirecodes

@foxfirecodes Thank you for confirming the suspicion! You've been immensely helpful!

thomasgtaylor avatar Jun 12 '25 23:06 thomasgtaylor

Thanks @foxfirecodes ! And sorry to claim you had a different issue @thomasgtaylor . Was trying to account for the fact that something still seemed off, and it's been a long time since I've visited this issue haha

AlecM33 avatar Jun 12 '25 23:06 AlecM33

i shipped a fix to include application.commands authorizations in the guild count. please confirm the numbers look right now, if not lmk!

foxfirecodes avatar Jun 14 '25 00:06 foxfirecodes