Git Product home page Git Product logo

Comments (7)

Qjuh avatar Qjuh commented on June 17, 2024

You are correct in that it sets the presence without checking if the gateway call to set the presence succeeded. The reason for this is because there’s no way to check it did. It‘s not a REST call that has a response. It‘s also not issuing a websocket receive event (unless you have GuildPresences intent). And if it didn’t go through the only reason could be it was because the websocket itself was hung up or reconnecting. In both cases the payload to set the presence will remain in the queue until connected again and then it will change.

about that „bug“ in discord-api (which was closed because it really isn’t a bug): you don’t need to periodically reset the presence if you passed it in the identify call (which djs allows you to do by passing presence: {…} in the Client constructor).

from discord.js.

JstnMcBrd avatar JstnMcBrd commented on June 17, 2024

about that „bug“ in discord-api (which was closed because it really isn’t a bug): you don’t need to periodically reset the presence if you passed it in the identify call (which djs allows you to do by passing presence: {…} in the Client constructor).

Oh, I had not heard about that solution to the activity-disappearing issue. In the issue thread (here), it sounded like it was just a longstanding bug in Discord's backend that wipes bot activities whenever they deploy code.

Everyone else in that thread seems to be unaware of that solution. Would you mind posting it there so it can be more widely known? I think they'd really appreciate it - people have been complaining about the bug for 5 years.

from discord.js.

JstnMcBrd avatar JstnMcBrd commented on June 17, 2024

You are correct in that it sets the presence without checking if the gateway call to set the presence succeeded. The reason for this is because there’s no way to check it did. It‘s not a REST call that has a response. It‘s also not issuing a websocket receive event (unless you have GuildPresences intent). And if it didn’t go through the only reason could be it was because the websocket itself was hung up or reconnecting. In both cases the payload to set the presence will remain in the queue until connected again and then it will change.

Okay, that's understandable. If there's no response, then you can't guarantee the API call succeeded.

But what about adding a way to directly fetch the user's presence? If that's part of the Discord API, it would be good to add to d.js. My example use case isn't applicable, but some users might appreciate a way to directly fetch the real-time value of the presence, rather than rely on the eventually-consistent nature of the websocket queue.

Of course, if that's not possible with the Discord API, please disregard.

from discord.js.

monbrey avatar monbrey commented on June 17, 2024

But what about adding a way to directly fetch the user's presence? If that's part of the Discord API, it would be good to add to d.js. My example use case isn't applicable, but some users might appreciate a way to directly fetch the real-time value of the presence, rather than rely on the eventually-consistent nature of the websocket queue.

Of course, if that's not possible with the Discord API, please disregard.

Presences aren't defined on the User object, they're a property of GuildMember made available by the GuildPresences intent. Fetching your bot's GuildMember (or accessing guild.members.me) with presences enabled should provide this information.

from discord.js.

JstnMcBrd avatar JstnMcBrd commented on June 17, 2024

Presences aren't defined on the User object, they're a property of GuildMember made available by the GuildPresences intent. Fetching your bot's GuildMember (or accessing guild.members.me) with presences enabled should provide this information.

Okay! Is there no way to do it outside the context of Guilds? It's understandable that it would be limited to Guilds for other users (GuildMember), but what about for the ClientUser, where the presence should be independent of Guilds?

Considering it seems like my feature requests are either A) not possible, or B) already included, I think I'll close the issue after these questions. Thank you!

from discord.js.

almostSouji avatar almostSouji commented on June 17, 2024

Presences are inherently guild-based data, so they can just be retrieved within a guild context; this is a discord API limitation.
As for the sending of presences, Qjuh covered that above.

from discord.js.

JstnMcBrd avatar JstnMcBrd commented on June 17, 2024

Thank you for the explanations!

from discord.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.