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

Error: Unknown Member in Channel#history #117

Open
DannyBen opened this issue Jan 10, 2022 · 5 comments · May be fixed by #204
Open

Error: Unknown Member in Channel#history #117

DannyBen opened this issue Jan 10, 2022 · 5 comments · May be fixed by #204

Comments

@DannyBen
Copy link

Description

When calling Channel#history with a limit larger than the amount of messages that exist in the channel, it would seem like the method is attempting to get author details for nil messages, and the result is this error appearing multiple times:

[ERROR : main @ 2022-01-10 11:00:39.235] Unknown Member
[ERROR : main @ 2022-01-10 11:00:39.511] Unknown Member
[ERROR : main @ 2022-01-10 11:00:39.803] Unknown Member
# ... Ctrl+C is required to abort
# and each line takes some 200ms to complete, hinting a web request is in progress.

Reproduction

Run the below code on a channel that has less than 100 messages.

require 'discordrb'
channel_id = 123 # replace me with a channel ID
bot = Discordrb::Bot.new token: ENV['BOT_TOKEN']
channel = bot.channel channel_id
pp channel.history 100

Environment

Ruby version:

ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

Discordrb version:

  * discordrb (3.4.2 a1083b0)
  * discordrb-webhooks (3.4.2 a1083b0)
@biqqles
Copy link
Contributor

biqqles commented Jul 22, 2022

Thank you for your detailed code but I am unable to reproduce this issue on either 3.4.0, the commit you listed or current main.

Could you check whether you get the same behaviour with a second channel with under 100 messages? My suspicion is that the issue is caused by another property of the channel you tested with, such as it including messages sent by an account which has left or been deleted.

@DannyBen
Copy link
Author

Could you check whether you get the same behaviour

Sorry, no - I since moved on and at this time, not making use of the library.
Feel free to close the issue if it is not reproducible.

@SolarizedPhoenix
Copy link

I seem to be getting this issue on messages where the user is no longer on the server, thing is it does this for each message, and does not seem to be caching the user, and keeps requesting them. This can quickky compound when a bot is attempting to read a lot of history at once, as it's possible each chunk of 100 messages can take up to 30s to complete, causing horrendous slowdown. Thing is, every message then has the info for the user, so it's still retrieving it, just refusing to either save the info, or load it from cache. I've attempted to use #ensure_user to manually cache it in case, but I either don't understand it, or it's also not working properly.

@swarley
Copy link
Member

swarley commented Mar 5, 2023

This is likely due to overeager attempts to resolve the full member object which a message does not provide. The solution is to populate this information lazily on our end

@biqqles
Copy link
Contributor

biqqles commented Mar 6, 2023

I have a fix for this but need to clean it up and post a PR. The relevant code is as expected in Message#initialize.

@biqqles biqqles linked a pull request Mar 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants