Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

How to get userid from username #317

Open

Description

@Unity123

I need to get the userid from the username so that my bot can mention a person given by the user.

Activity

  1. ClearlyElevated commented on Sep 14, 2019

    @ClearlyElevated

    you can use any other bot or put a code block around the username to cause it not to work and give the user ID

  2. ClearlyElevated commented on Sep 14, 2019

    @ClearlyElevated

    this isnt a lib issue

  3. soryy708 commented on Dec 28, 2019

    @soryy708
        function getUserId(bot, serverId, username) {
            const server = bot.servers[serverId];
            const userMatch = Object.values(bot.users).find(user => user.username.toLowerCase() === username.toLowerCase());
            if (userMatch) {
                return userMatch.id;
            }
            const nickMatch = Object.values(server.members).find(member => member.nick && member.nick.toLowerCase() === username.toLowerCase());
            if (nickMatch) {
                return nickMatch.id;
            }
            return null;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions