Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added guilds array and count to ready_t #1038

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

Jaskowicz1
Copy link
Contributor

This PR adds the guilds array and a count of the array to the ready_t event, as Discord provides an array of unavailable guilds on the ready event. This means people can now get the amount of guilds a bot is in from the ready_t event.

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

@Jaskowicz1 Jaskowicz1 self-assigned this Dec 7, 2023
Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit f8d94c2
🔍 Latest deploy log https://app.netlify.com/sites/dpp-dev/deploys/6571a1d5114a3c0008b5f73e
😎 Deploy Preview https://deploy-preview-1038--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added documentation Improvements or additions to documentation code Improvements or additions to code. labels Dec 7, 2023
@Jaskowicz1
Copy link
Contributor Author

Here's some images of it!

demo1
demo2

@Jaskowicz1 Jaskowicz1 merged commit 6a821cb into brainboxdotcc:dev Dec 7, 2023
43 checks passed
@Jaskowicz1 Jaskowicz1 deleted the ready-event-changes branch December 7, 2023 13:21
@razaqq
Copy link

razaqq commented Dec 12, 2023

For me accessing dpp::ready_t::guilds results in a segfault.

guilds

@Jaskowicz1
Copy link
Contributor Author

For me accessing dpp::ready_t::guilds results in a segfault.

Can you send the raw event please? Remember to take out sensitive information.

@razaqq
Copy link

razaqq commented Dec 12, 2023

the bot is in guilds, so guild_count being 0 makes no sense either.

raw event:

{
  "t": "READY",
  "s": 1,
  "op": 0,
  "d": {
    "v": 10,
    "user_settings": {
      
    },
    "user": {
      "verified": true,
      "username": "REDACTED",
      "mfa_enabled": true,
      "id": "REDACTED",
      "global_name": null,
      "flags": 0,
      "email": null,
      "discriminator": "REDACTED",
      "bot": true,
      "avatar": null
    },
    "shard": [
      0,
      1
    ],
    "session_type": "normal",
    "session_id": "REDACTED",
    "resume_gateway_url": "REDACTED",
    "relationships": [
      
    ],
    "private_channels": [
      
    ],
    "presences": [
      
    ],
    "guilds": [
      {
        "unavailable": true,
        "id": "REDACTED"
      }
    ],
    "guild_join_requests": [
      
    ],
    "geo_ordered_rtc_regions": [
      "REDACTED",
      "REDACTED",
      "REDACTED",
      "REDACTED",
      "REDACTED"
    ],
    "current_location": [
      "REDACTED",
      "REDACTED"
    ],
    "auth": {
      
    },
    "application": {
      "id": "REDACTED",
      "flags": 8421376
    },
    "_trace": [
      "[\"gateway-prd-us-east1-b-lz5w\",{\"micros\":91431,\"calls\":[\"id_created\",{\"micros\":1089,\"calls\":[]},\"session_lookup_time\",{\"micros\":4560,\"calls\":[]},\"session_lookup_finished\",{\"micros\":16,\"calls\":[]},\"discord-sessions-prd-2-85\",{\"micros\":85342,\"calls\":[\"start_session\",{\"micros\":75877,\"calls\":[\"discord-api-7865c84bc5-f4jll\",{\"micros\":61109,\"calls\":[\"get_user\",{\"micros\":9624},\"get_guilds\",{\"micros\":8391},\"send_scheduled_deletion_message\",{\"micros\":11},\"guild_join_requests\",{\"micros\":10},\"authorized_ip_coro\",{\"micros\":12}]}]},\"starting_guild_connect\",{\"micros\":58,\"calls\":[]},\"presence_started\",{\"micros\":316,\"calls\":[]},\"guilds_started\",{\"micros\":99,\"calls\":[]},\"guilds_connect\",{\"micros\":2,\"calls\":[]},\"presence_connect\",{\"micros\":8935,\"calls\":[]},\"connect_finished\",{\"micros\":8942,\"calls\":[]},\"build_ready\",{\"micros\":21,\"calls\":[]},\"clean_ready\",{\"micros\":26,\"calls\":[]},\"optimize_ready\",{\"micros\":1,\"calls\":[]},\"split_ready\",{\"micros\":0,\"calls\":[]}]}]}]"
    ]
  }
}

@Mishura4
Copy link
Member

Just to make sure, your application is using the updated DPP library right? Not an older version?

@Mishura4
Copy link
Member

For example using updated headers but an older libdpp.so can cause things like this

@razaqq
Copy link

razaqq commented Dec 12, 2023

yes, but i fear it might be some cmake cache

edit: yep, works now

@razaqq
Copy link

razaqq commented Dec 12, 2023

the only thing i noticed is you cannot access the guild cache dpp::find_guild(id) in on_ready since guilds arent cached yet.
if you use bot.guild_get(id) to access the guild, certain fields like dpp::guild::members and dpp::guild::member_count arent populated yet.

@Jaskowicz1
Copy link
Contributor Author

the only thing i noticed is you cannot access the guild cache dpp::find_guild(id) in on_ready since guilds arent cached yet.

if you use bot.guild_get(id) to access the guild, certain fields like dpp::guild::members and dpp::guild::member_count arent populated yet.

Yes we know, that's why this PR exists and is also completely unrelated.

Discord sends an array of guilds with the Ready event, we are now acknowledging it and exposing it to users so they can set the status on ready instantly.

Double check your version is right with DPP_VERSION_LONG (when running the bot, don't just look at the header and assume). If you are on 10.0.29, open an issue ticket please.

@Mishura4
Copy link
Member

Yes. Guild members are given separately after the ready event, if you have the guild members intent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Improvements or additions to code. documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants