25
u/natemi10 Sep 17 '19
Sure, get the member of the message by going through all the members in the server and checking whether they have the same id as the member that sent the message.
7
u/ColdSnickersBar Sep 17 '19
What if the members of
commandData.client.guilds.membersare a different type thancommandData.message.author? Especially if guild members aren't necessarily message authors in whatever product this is.I don't see anything in this example that would lead me to believe that we can trust the author is a in the list of members, or even that they're the same type at all.
10
u/spaghettu Sep 17 '19
So we have a message author, which presumably is the same type as member, but we need to see if they belong to a guild member list. So they search the guild list with find for that member id. Maybe the search is linear (I don't use JS so I'm not familiar), but I otherwise don't see the problem. I guess it'd be faster if each member already had a list of guilds it was a member of directly on the object, but I mean to me this doesn't seem that bad. Am I missing something?
5
u/3636373536333662 Sep 17 '19
Seems fine to me too. The search is linear, but it won't really matter unless the guild list is quite large.
1
u/Plus_Cryptographer Sep 19 '19
Seems like the problem here would more be that you are checking for a command in a server, and then immediately check if the person sending that is on the server.
e.g. between when the user sent their command and you checking it, it's possible that the user left the server?
24
u/00benallen Sep 17 '19
I'm not noticing what's so bad about this. This is what data from large APIs generally looks like, the code author seems to be coding correctly.