Find Discord member ID by name
TL;DR
About
Discord hides user IDs until you turn on Developer Mode (User Settings > Advanced) and right-click someone to copy theirs. Fine for one person. An agent posting for you has it harder, because a real mention must be written as <@userId>. You pass a name, or the start of one, and the link to a channel in that person's server. The lookup types @name into that channel's message box, reads the IDs off the mention popup and clears the box without sending. Say a moderator's agent is posting the Friday scrim lineup. It passes "marta" with the #general link, gets her ID plus any other Martas in matches, and checks the label before writing <@userId>. A bot can run a similar prefix search on usernames and nicknames through Discord's Search Guild Members endpoint, once someone with Manage Server adds it. The catch is that you must be signed in, and only members of that channel's server show up.
Input
name requiredName (or start of the name) of the member to resolve. Throws when no member matches.
channelUrl requiredURL of a channel in the server to search, e.g. https://discord.com/channels/<guildId>/<channelId>. Must be a channel the signed-in account can type in (the lookup runs through that channel's message box).
Output
userId requireduserId of the first result (best match), or null.
matches requiredAll members offered by the autocomplete, best first.
Example output
Shape only: placeholder values generated from the output schema, not a real run.
{
"userId": "abc123",
"matches": [
{
"label": "Example",
"userId": "abc123"
}
]
}