userConverter top-level constant Null safety

Converter<IUser> const userConverter

Converter to convert input to IUsers.

This uses multiple strategies to look up users, in the order below:

  • ID lookup (parse input as snowflake)
  • Member lookup (convert to member using memberConverter and extract IMember.user)
  • Exact username match
  • Full case insensitive username match
  • Partial case insensitive username match (username starts with input)

Note that for all of these strategies, if multiple users match any condition then no results will be given based off of that condition.

Implementation

const Converter<IUser> userConverter = FallbackConverter<IUser>(
  [
    CombineConverter<Snowflake, IUser>(snowflakeConverter, snowflakeToUser),
    CombineConverter<IMember, IUser>(memberConverter, memberToUser),
    Converter<IUser>(convertUser),
  ],
  type: CommandOptionType.user,
);