crycode-de / ioBroker.discord

ioBroker Discord bot integration
MIT License
6 stars 4 forks source link

Error while updating user presence #60

Closed pafade89 closed 5 months ago

pafade89 commented 5 months ago

Describe the bug

I've been getting the following warning for some time now:

discord.0 | 2024-05-08 13:33:50.507 | warn | Error while updating user presence of user 345476828393373707: Error: undefined is not a valid state value

Versions:

crycode-de commented 5 months ago

Thank you for reporting this issue!

Does this happen for every user presence change or only for specific changes?

Can you post the content of the users json state when the warning is logged? Should be the state discord.0.users.345476828393373707.json according to your posted error message.

pafade89 commented 5 months ago

The error occurs when joining a server, but strangely, only for one user.

{"id":"345476828393373707","tag":"test","name":"test","activityName":"Hang Status","avatarUrl":"https://cdn.discordapp.com/avatars/345476828393373707/7adb04e4401ef8a480cefa9b7d5c4c97.webp","bot":false,"status":"online"}

I suspect the new Discord activities are causing the issue.

image

crycode-de commented 5 months ago

In the json the activityType property is missing. So it's definitely related to the activity type and some activity type unknown to the adapter. Where do I set this new activities?

crycode-de commented 5 months ago

@pafade89 Maybe you can install and try the current version from GitHub? This should fix the undefined value for unknown activity types by setting an empty string in this case. For a better fix I need to reproduce this in debugger mode on my machine.

Ye4ck commented 5 months ago

@pafade89 Maybe you can install and try the current version from GitHub? This should fix the undefined value for unknown activity types by setting an empty string in this case. For a better fix I need to reproduce this in debugger mode on my machine.

Discord gives this type of activity "random" to servers for a short time, after that time other servers can use it, etc. It´s hard to reproduce it if your server doesn´t have those activities now.

pafade89 commented 5 months ago

@pafade89 Maybe you can install and try the current version from GitHub? This should fix the undefined value for unknown activity types by setting an empty string in this case. For a better fix I need to reproduce this in debugger mode on my machine.

I can currently only test it through the Discord mobile app, but it seems to be working.

Thank you very much for your fast first support.

crycode-de commented 5 months ago

@pafade89 I've just added some debug output while updating the user presence. Maybe we are able to narrow down what discord is doing here on custom activities.

I guess there is a new activity type ID. But I could not find anything related to this in the discord API doc or the discord.js docs.

Could you install the current version from GitHub and enable debug logging for the adapter? The relevant debug logs are something like

discord.0 (1323) User presence of user 490222742801481728: {"status":"online","activityName":"","activityType":"Custom"} {"name":"Custom Status","type":4,"url":null,"details":null,"state":null,"applicationId":null,"timestamps":{"start":null,"end":"2024-05-10T08:49:47.778Z"},"party":null,"syncId":null,"assets":null,"flags":0,"emoji":{"animated":null,"name":"🙄","id":null,"createdTimestamp":null,"identifier":"%F0%9F%99%84","imageURL":null},"buttons":[],"createdTimestamp":1715329188896}

for the user using a custom activity. Mainly the part "type":4, where 4 in this example is Custom. Would be nice if you can post some of the debug logs. 🙂

pafade89 commented 5 months ago

@crycode-de I think that isn't really helpful, is it?

2024-05-14 11:00:15.043 - debug: discord.0 (76420) Redis Objects: Use Redis connection: 127.0.0.1:6379
2024-05-14 11:00:15.057 - debug: discord.0 (76420) Objects client ready ... initialize now
2024-05-14 11:00:15.058 - debug: discord.0 (76420) Objects create System PubSub Client
2024-05-14 11:00:15.058 - debug: discord.0 (76420) Objects create User PubSub Client
2024-05-14 11:00:15.076 - debug: discord.0 (76420) Objects client initialize lua scripts
2024-05-14 11:00:15.081 - debug: discord.0 (76420) Objects connected to redis: 127.0.0.1:6379
2024-05-14 11:00:15.084 - debug: discord.0 (76420) Redis States: Use Redis connection: 127.0.0.1:6379
2024-05-14 11:00:15.086 - debug: discord.0 (76420) States create System PubSub Client
2024-05-14 11:00:15.086 - debug: discord.0 (76420) States create User PubSub Client
2024-05-14 11:00:15.089 - debug: discord.0 (76420) States connected to redis: 127.0.0.1:6379
2024-05-14 11:00:15.098 - debug: discord.0 (76420) Plugin sentry Initialize Plugin (enabled=true)
2024-05-14 11:00:15.214 - info: discord.0 (76420) starting. Version 2.2.1 (non-npm: crycode-de/ioBroker.discord) in /opt/iobroker/node_modules/iobroker.discord, node: v18.20.1, js-controller: 5.0.19
2024-05-14 11:00:15.228 - debug: discord.0 (76420) Version of discord.js: 14.14.1
2024-05-14 11:00:15.268 - debug: discord.0 (76420) Get all objects with custom config ...
2024-05-14 11:00:15.274 - debug: discord.0 (76420) Getting all objects with custom config done
2024-05-14 11:00:16.172 - debug: discord.0 (76420) Commands not enabled
2024-05-14 11:00:16.193 - info: discord.0 (76420) Discord client websocket connected (shardId:0)
2024-05-14 11:00:16.194 - info: discord.0 (76420) Logged in as ioBroker Bot#0000!
2024-05-14 11:00:16.194 - debug: discord.0 (76420) User ID: xxx
2024-05-14 11:00:16.204 - debug: discord.0 (76420) Set bot presence: {"status":"online","activities":[{"type":5,"name":"ioBroker"}]}
2024-05-14 11:00:19.580 - debug: discord.0 (76420) Known user: test1 id:225322146186919949
2024-05-14 11:00:19.587 - debug: discord.0 (76420) User presence of user 225322146186919949: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.589 - debug: discord.0 (76420) User presence of user 225322146186919949: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.590 - debug: discord.0 (76420) Known user: test2. id:296247581506404354
2024-05-14 11:00:19.597 - debug: discord.0 (76420) User presence of user 296247581506404354: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.598 - debug: discord.0 (76420) User presence of user 296247581506404354: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.600 - debug: discord.0 (76420) Known user: test3 id:305941085170171906
2024-05-14 11:00:19.605 - debug: discord.0 (76420) User presence of user 305941085170171906: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.608 - debug: discord.0 (76420) User presence of user 305941085170171906: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.610 - debug: discord.0 (76420) Known user: test4 id:345476828393373707
2024-05-14 11:00:19.617 - debug: discord.0 (76420) User presence of user 345476828393373707: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.618 - debug: discord.0 (76420) User presence of user 345476828393373707: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.620 - debug: discord.0 (76420) Known user: test5 id:349261712119300098
2024-05-14 11:00:19.627 - debug: discord.0 (76420) User presence of user 349261712119300098: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.629 - debug: discord.0 (76420) User presence of user 349261712119300098: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.632 - debug: discord.0 (76420) Known user: test6 id:548810789545443340
2024-05-14 11:00:19.639 - debug: discord.0 (76420) User presence of user 548810789545443340: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.641 - debug: discord.0 (76420) User presence of user 548810789545443340: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.643 - debug: discord.0 (76420) Known user: test7 id:549644912669360138
2024-05-14 11:00:19.651 - debug: discord.0 (76420) User presence of user 549644912669360138: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.652 - debug: discord.0 (76420) User presence of user 549644912669360138: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.655 - debug: discord.0 (76420) Known user: test8 id:705769488301162497
2024-05-14 11:00:19.661 - debug: discord.0 (76420) User presence of user 705769488301162497: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.663 - debug: discord.0 (76420) User presence of user 705769488301162497: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.665 - debug: discord.0 (76420) Known user: test9 id:753903272883912726
2024-05-14 11:00:19.672 - debug: discord.0 (76420) User presence of user 753903272883912726: {"status":"","activityName":"","activityType":""} undefined
2024-05-14 11:00:19.674 - debug: discord.0 (76420) User presence of user 753903272883912726: {"status":"","activityName":"","activityType":""} undefined
crycode-de commented 5 months ago

@pafade89 Thank you! This was quite helpful. The undefined at the end shows me, that there are no activities reported by the Discord API. So in this case there is nothing we can do to get some information about the custom activities.

I'll remove this debug output and release a new latest version containing the fix mentioned earlier. 🙂

pafade89 commented 5 months ago

Thank you once again for your great support!