This can be problematic. One has to avoid using commands with multiple mentions as arguments, otherwise they have to compare the clean text of the message versus the mentions and reorder them. This should most definitely be handled by the library.
I agree that this would be nice, but in my opinion this is not a bug - nowhere does it say that it's intended to be ordered. I'll reclassify it as enhancement.
Its expected to be ordered, even if it doesn't say it should be.
There's no point of it being ordered in my opinion. What happens if a user is mentioned multiple times in a message? I think it'd be better to just go through message.content with a regex to extract IDs, and then match the IDs to the user using something like client.users.get("id", id)
Right. That should be handled by the library, prior to it being handled by the bot.
As for how this can be an issue? Say I have command >>fight. Syntax is >>fight @user1 action @user2. If the order isn't set, then they have to at least find the indexOf values of each and compare them, which is something more complicated than things the library already handles. If they don't bother. It might end up that user2 uses action on user1 instead of the otherway around. Quite counter intuitive.
As far as a user being mentioned multiple times?..... can't you have it reference the first instance in the cache?
Also, I have not seen any instances (aside from spammers) where there's ever been _that_ many more mentions than 1xUser, and rarely more than 1xUserxMessage. I don't think that having duplicate user objects in the mention cache would be of a considerable resource waste.
@hydrabolt if the user is mentioned multiple times, put them in the array multiple times. It should definitely be ordered.
discord.js currently runs off the mentions array, which appears to be out of order and doesn't contain repeated mentions...
👋 just ran into this issue with the latest release. I guess this has been resolved by e3173d1, and it's been tagged 11.2.0, but it looks like that commit hasn't been merged to stable. Is a fix for this still going ahead at some point?
@ThomasShaped the library was entirely rewritten since that commit, and now resides in src/structures/MessageMentions.js
Thought it looked a bit old, my bad 😅 Still, would be nice to have this, or at least documentation that the collection is ID ordered. The method names ‘first’ and ‘last’ are semi-misleading when using them with respect to mentions imo, which I expected to be ordered in the order they appear.
Can we get this issue locked? And may I suggest all issues older than the latest rewrite get locked as well?
Most helpful comment
Thought it looked a bit old, my bad 😅 Still, would be nice to have this, or at least documentation that the collection is ID ordered. The method names ‘first’ and ‘last’ are semi-misleading when using them with respect to mentions imo, which I expected to be ordered in the order they appear.