memberConverter top-level constant Null safety

Converter<IMember> const memberConverter

Converter to convert input to IMembers.

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

  • ID lookup (parse input as snowflake or mention)
  • Exact username match
  • Exact nickname match
  • Full case insensitive username match
  • Full case insensitive nickname match
  • Partial case insensitive username match (username starts with input)
  • Partial case insensitive nickname match (nickname starts with input)

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

Implementation

const Converter<IMember> memberConverter = FallbackConverter<IMember>(
  [
    // Get member from mention or snowflake.
    CombineConverter<Snowflake, IMember>(snowflakeConverter, snowflakeToMember),
    // Get member by name or nickname
    Converter<IMember>(convertMember),
  ],
  type: CommandOptionType.user,
);