Comments (7)
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.
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.
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.
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.
Presences aren't defined on the
User
object, they're a property ofGuildMember
made available by theGuildPresences
intent. Fetching your bot'sGuildMember
(or accessingguild.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.
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.
Thank you for the explanations!
from discord.js.
Related Issues (20)
- [SlashCommandStringOptions] Be able to pass arguments to the constructor, or more builder options for SlashCommandStringOption HOT 2
- Publish a new release (dev build points to /ws that doesn't include a fix) HOT 3
- ClientPresenceStatusData Canary and PTB HOT 1
- ActionRowBuilder Constructor improperly merging provided components into new componentbuilders HOT 4
- Client is not receiving 'messageCreate' events HOT 1
- .toJSON() is 'unknown' HOT 1
- crashing after message deletion HOT 5
- Using channel.send on a channel where the bot has not the permission to post makes the whole program crash HOT 3
- Kicking the bot from its dev guild and inviting it again drops the slash commands HOT 6
- Automated Message nonce handling HOT 1
- Emit poll events on uncached messages
- `ws` throws `TypeError: Cannot use 'in' operator to search for 'code' in undefined` when with Deno HOT 6
- Wrong base URL for GIF stickers
- [Typing] `interaction.followUp()` should not have `ephemeral` in its options? HOT 6
- oops HOT 1
- Uncaught exception when adding member that is already part of the guild
- Readonly arrays in interfaces don't allow dynamically adding data
- Allow InteractionOptionResolvers to return the raw value for different option types (like user) HOT 4
- DiscordAPIError[10062]: Unknown interaction (AutoComplete) HOT 1
- Cannot add user option when using localizations HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discord.js.