estarossa0 / bmo

bot for the 1337 school discord server
20 stars 4 forks source link

[feat/command]: Find Discord user based on intra username #12

Closed elbourki closed 2 years ago

elbourki commented 2 years ago

It's sometimes cumbersome to find a user based on their intra username because of Discord's broken search functionality, especially when looking for them during an evaluation. Here's an example from the mobile Discord app when searching for a perfectly valid intra username:

image

The sidebar also doesn't show offline users so it makes sense to add this command.

I expect this command to accept a username argument. We can then use the input to look for the user using the following endpoint:

https://discord.com/developers/docs/resources/guild#search-guild-members

Once we find a match, we return the student's Discord nickname and a link in the following format so you can easily DM them:

https://discord.com/channels/@me/[students_discord_id]

estarossa0 commented 2 years ago

Sorry for reaching back late. I gotta admin that this happen from time to time due to discord misleading search ui, the search bar in the right side of server is for messages not members, and you gotta use the one in the left instead or using cmd+k image but some users whom you haven't interact with before in channels may not be shown cause of discord cache search.

Although unfortunately this search command may not be added due to the rate limit within users fetch discord have and it may cause BMO to get banned by discord. So such a command work BMO need to fetch all users once and save them in a database and search in database instead of fetch result, fortunately, Emet bot have this already so this feature will be added to it instead to solve the search problem

elbourki commented 2 years ago

Sounds good. Let me know if I can help with adding this to Emet.