discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.47k stars 3.97k forks source link

Activites messages going away after updating to 13.8.0 #8062

Closed Mirai-Miki closed 2 years ago

Mirai-Miki commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

Since updating to 13.8.0 from 13.7.0 the activity messages on the bots have been going away after a seemingly random amount of time (sometimes 10min sometimes a few hours).

I haven't changed any code to do with updating the activity messages in like a year and always functioned correctly before. Not getting any error messages either.

In my bots the activity message is updated whenever the bot joins or leaves a guild. And doing so will bring the message back, but after some time it will go away again.

Cannot seem to locate any issues on my end so I suspect it is on discord.js side.

Code sample

'use strict';
module.exports = {
    name: 'guildCreate',
    once: false,
    execute(guild) {
            guild.client.user.setActivity(`${guild.client.guilds.cache.size} Servers`, { type: 'WATCHING' });
    },
};

Package version

13.8.0

Node.js version

v18.0.0

Operating system

Debian 4.19.132-1 (2020-07-24)

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, DirectMessages

I have tested this issue on a development release

No response

didinele commented 2 years ago

Hi there! Your bot's status is controlled via the gateway and is not guaranteed to persist, it never was. Discord resets connections or otherwise state which causes the status to go away.

The fact that it started happening more frequently for you as of 13.8.0 is most definitely a coincidence. I advise setting your bot's status on an interval as well to maintain it.

Mirai-Miki commented 2 years ago

The bots have been live for over a year and I have never seen the status down before. The fact that now they are down more then they are up all of a sudden suggests more then just a coincidence.

I can put them on a timer to correct for whatever if causing it but the fact that I have to do it, suggests a problem since there never was any need before.

didinele commented 2 years ago

You're more than welcome to try downgrading to 13.7.0 to see if you still run into this, but I'm fairly confident that you will.

suggests more then just a coincidence

I didn't deny that it's actually happening more often, I simply implied that Discord may have changed something as we did (which is very possible, given they're messing with with the message intent), especially since 13.8.0 doesn't seem to have touched anything regarding presences.

bribes commented 2 years ago

Hi there! Your bot's status is controlled via the gateway and is not guaranteed to persist, it never was. Discord resets connections or otherwise state which causes the status to go away.

The fact that it started happening more frequently for you as of 13.8.0 is most definitely a coincidence. I advise setting your bot's status on an interval as well to maintain it.

What is a ideal interval for keeping your bots status up?

Mirai-Miki commented 2 years ago

I didn't deny that it's actually happening more often

Fair enough and you are correct, it could very well be discord, or even the cloud host if a spotty connection could effect it. It is barely even a nuisance for me in any case. I also don't know what was or wasn't changed during the update, I just put this up because it doesn't seem to be coming from my end and since there was no issue with the system before, I figure it worth mentioning.

What is a ideal interval for keeping your bots status up?

It shouldn't really matter, a single timer going off even every minute shouldn't effect performance much. I will probably set one about every hour or two just because I don't care if it is down for that long.

MaksiRose commented 2 years ago

@Mirai-Miki The way I solved this issue is by putting the setActivity method inside the shardReady event. Whenever the connection drops and then reconnects, this seems to update the status, and so far this prevented the status from disappearing. I don't know if I have been lucky or if this is a definite solution as I am neither fully knowledgeable on shards nor on the shardReady event but hey, it worked for me.

Mirai-Miki commented 2 years ago

@Mirai-Miki The way I solved this issue is by putting the setActivity method inside the shardReady event. Whenever the connection drops and then reconnects, this seems to update the status, and so far this prevented the status from disappearing. I don't know if I have been lucky or if this is a definite solution as I am neither fully knowledgeable on shards nor on the shardReady event but hey, it worked for me.

I don't use shards yet. And my bots update in the 'ready', 'guildCreate' and 'guildDelete' events. I assume 'ready' is the equivalent to 'shardReady'.

Checking my bots today the activity on all three are up and there doesn't seem to be a change in the number of servers so perhaps whatever was causing the issue is resolved? Perhaps it was something on Discords end after all. I will keep an eye on it, if it seems like whatever it is has resolved I will close the issue.

MaksiRose commented 2 years ago

@Mirai-Miki The way I solved this issue is by putting the setActivity method inside the shardReady event. Whenever the connection drops and then reconnects, this seems to update the status, and so far this prevented the status from disappearing. I don't know if I have been lucky or if this is a definite solution as I am neither fully knowledgeable on shards nor on the shardReady event but hey, it worked for me.

I don't use shards yet. And my bots update in the 'ready', 'guildCreate' and 'guildDelete' events. I assume 'ready' is the equivalent to 'shardReady'.

Checking my bots today the activity on all three are up and there doesn't seem to be a change in the number of servers so perhaps whatever was causing the issue is resolved? Perhaps it was something on Discords end after all. I will keep an eye on it, if it seems like whatever it is has resolved I will close the issue.

I also don't use shards. Which is why I don't know how shards work, as I said. But this is a lie, since we both technically use shards, namely we use one shard. And this is important when understanding how "ready" and "shardReady" seem to be operating:

For this reason, I use "shardReady" since it seems to be doing exactly what I want it to do, namely updating the setActivity every time Discord resets the connection or the bot loses connection to Discord in some way, which is also the same time that activity would be reset, so it does it whenever needed and not more or less.

Mirai-Miki commented 2 years ago

@MaksiRose hmm that is interesting. I might look into that as well. And to be fair I will actually have to move to shards at some point soon anyway.

almostSouji commented 2 years ago

Persistence frames of presences are on Discord, randomly resetting is not new, and your update to 13.8.0 is very likely a coincidence in the timeline. Use a sensible interval timer and send the presence again (I would personally advise to keep it above or at least in the region of 1m)