Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Collection<string, User>
    • Owners

Index

Constructors

constructor

Properties

Readonly [toStringTag]

[toStringTag]: string

constructor

constructor: CollectionConstructor

Readonly koreanbots

koreanbots: Koreanbots

Readonly size

size: number

Static Readonly [species]

[species]: MapConstructor

Static Readonly default

default: typeof Collection

Methods

[iterator]

  • [iterator](): IterableIterator<[string, User]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[string, User]>

clear

  • clear(): void
  • Identical to Map.clear(). Removes all elements from the collection.

    Returns void

clone

  • clone(): Collection<string, User>
  • Creates an identical shallow copy of this collection.

    example

    const newColl = someColl.clone();

    Returns Collection<string, User>

concat

  • concat(...collections: Collection<string, User>[]): Collection<string, User>
  • Combines this collection with others into a new collection. None of the source collections are modified.

    example

    const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);

    Parameters

    • Rest ...collections: Collection<string, User>[]

      Collections to merge

    Returns Collection<string, User>

delete

  • delete(key: string): boolean
  • Identical to Map.delete(). Deletes an element from the collection.

    Parameters

    • key: string

      The key to delete from the collection

    Returns boolean

    true if the element was removed, false if the element does not exist.

difference

  • difference(other: Collection<string, User>): Collection<string, User>
  • The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.

    Parameters

    • other: Collection<string, User>

      The other Collection to filter against

    Returns Collection<string, User>

each

  • Identical to Map.forEach(), but returns the collection instead of undefined.

    example

    collection .each(user => console.log(user.username)) .filter(user => user.bot) .each(user => console.log(user.username));

    Parameters

    • fn: (value: User, key: string, collection: Owners) => void

      Function to execute for each element

        • (value: User, key: string, collection: Owners): void
        • Parameters

          Returns void

    Returns Owners

  • Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => void
        • (value: User, key: string, collection: Owners): void
        • Parameters

          Returns void

    • thisArg: T

    Returns Owners

entries

  • entries(): IterableIterator<[string, User]>
  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[string, User]>

equals

  • equals(collection: Collection<string, User>): boolean
  • Checks if this collection shares identical items with another. This is different to checking for equality using equal-signs, because the collections may be different objects, but contain the same data.

    Parameters

    • collection: Collection<string, User>

      Collection to compare with

    Returns boolean

    Whether the collections have identical contents

every

  • every<K2>(fn: (value: User, key: string, collection: Owners) => key is K2): this is Collection<K2, User>
  • every<V2>(fn: (value: User, key: string, collection: Owners) => value is V2): this is Collection<string, V2>
  • every(fn: (value: User, key: string, collection: Owners) => boolean): boolean
  • every<This, K2>(fn: (value: User, key: string, collection: Owners) => key is K2, thisArg: This): this is Collection<K2, User>
  • every<This, V2>(fn: (value: User, key: string, collection: Owners) => value is V2, thisArg: This): this is Collection<string, V2>
  • every<This>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: This): boolean
  • Checks if all items passes a test. Identical in behavior to Array.every().

    example

    collection.every(user => !user.bot);

    Type parameters

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2

      Function used to test (should return a boolean)

        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    Returns this is Collection<K2, User>

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    Returns this is Collection<string, V2>

  • Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Type parameters

    • This

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2
        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    • thisArg: This

    Returns this is Collection<K2, User>

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    • thisArg: This

    Returns this is Collection<string, V2>

  • Type parameters

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: This

    Returns boolean

fetch

filter

  • filter<K2>(fn: (value: User, key: string, collection: Owners) => key is K2): Collection<K2, User>
  • filter<V2>(fn: (value: User, key: string, collection: Owners) => value is V2): Collection<string, V2>
  • filter(fn: (value: User, key: string, collection: Owners) => boolean): Collection<string, User>
  • filter<This, K2>(fn: (value: User, key: string, collection: Owners) => key is K2, thisArg: This): Collection<K2, User>
  • filter<This, V2>(fn: (value: User, key: string, collection: Owners) => value is V2, thisArg: This): Collection<string, V2>
  • filter<This>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: This): Collection<string, User>
  • Identical to Array.filter(), but returns a Collection instead of an Array.

    example

    collection.filter(user => user.username === 'Bob');

    Type parameters

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2

      The function to test with (should return boolean)

        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    Returns Collection<K2, User>

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    Returns Collection<string, V2>

  • Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns Collection<string, User>

  • Type parameters

    • This

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2
        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    • thisArg: This

    Returns Collection<K2, User>

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    • thisArg: This

    Returns Collection<string, V2>

  • Type parameters

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: This

    Returns Collection<string, User>

find

  • find<V2>(fn: (value: User, key: string, collection: Owners) => value is V2): undefined | V2
  • find(fn: (value: User, key: string, collection: Owners) => boolean): undefined | User
  • find<This, V2>(fn: (value: User, key: string, collection: Owners) => value is V2, thisArg: This): undefined | V2
  • find<This>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: This): undefined | User
  • Searches for a single item where the given function returns a truthy value. This behaves like Array.find(). All collections used in Discord.js are mapped using their id property, and if you want to find by id you should use the get method. See MDN for details.

    example

    collection.find(user => user.username === 'Bob');

    Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2

      The function to test with (should return boolean)

        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    Returns undefined | V2

  • Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns undefined | User

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    • thisArg: This

    Returns undefined | V2

  • Type parameters

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: This

    Returns undefined | User

findKey

  • findKey<K2>(fn: (value: User, key: string, collection: Owners) => key is K2): undefined | K2
  • findKey(fn: (value: User, key: string, collection: Owners) => boolean): undefined | string
  • findKey<This, K2>(fn: (value: User, key: string, collection: Owners) => key is K2, thisArg: This): undefined | K2
  • findKey<This>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: This): undefined | string
  • Searches for the key of a single item where the given function returns a truthy value. This behaves like Array.findIndex(), but returns the key rather than the positional index.

    example

    collection.findKey(user => user.username === 'Bob');

    Type parameters

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2

      The function to test with (should return boolean)

        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    Returns undefined | K2

  • Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns undefined | string

  • Type parameters

    • This

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2
        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    • thisArg: This

    Returns undefined | K2

  • Type parameters

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: This

    Returns undefined | string

first

  • first(): undefined | User
  • first(amount: number): User[]
  • Obtains the first value(s) in this collection.

    Returns undefined | User

    A single value if no amount is provided or an array of values, starting from the end if amount is negative

  • Parameters

    • amount: number

    Returns User[]

firstKey

  • firstKey(): undefined | string
  • firstKey(amount: number): string[]
  • Obtains the first key(s) in this collection.

    Returns undefined | string

    A single key if no amount is provided or an array of keys, starting from the end if amount is negative

  • Parameters

    • amount: number

    Returns string[]

flatMap

  • flatMap<T>(fn: (value: User, key: string, collection: Owners) => Collection<string, T>): Collection<string, T>
  • flatMap<T, This>(fn: (value: User, key: string, collection: Owners) => Collection<string, T>, thisArg: This): Collection<string, T>
  • Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to Array.flatMap().

    example

    collection.flatMap(guild => guild.members.cache);

    Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => Collection<string, T>

      Function that produces a new Collection

        • (value: User, key: string, collection: Owners): Collection<string, T>
        • Parameters

          Returns Collection<string, T>

    Returns Collection<string, T>

  • Type parameters

    • T

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => Collection<string, T>
        • (value: User, key: string, collection: Owners): Collection<string, T>
        • Parameters

          Returns Collection<string, T>

    • thisArg: This

    Returns Collection<string, T>

forEach

  • forEach(callbackfn: (value: User, key: string, map: Map<string, User>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: User, key: string, map: Map<string, User>) => void
        • (value: User, key: string, map: Map<string, User>): void
        • Parameters

          • value: User
          • key: string
          • map: Map<string, User>

          Returns void

    • Optional thisArg: any

    Returns void

get

  • get(key: string): undefined | User
  • Identical to Map.get(). Gets an element with the specified key, and returns its value, or undefined if the element does not exist.

    Parameters

    • key: string

      The key to get from this collection

    Returns undefined | User

has

  • has(key: string): boolean
  • Identical to Map.has(). Checks if an element exists in the collection.

    Parameters

    • key: string

      The key of the element to check for

    Returns boolean

    true if the element exists, false if it does not exist.

hasAll

  • hasAll(...keys: string[]): boolean
  • Checks if all of the elements exist in the collection.

    Parameters

    • Rest ...keys: string[]

      The keys of the elements to check for

    Returns boolean

    true if all of the elements exist, false if at least one does not exist.

hasAny

  • hasAny(...keys: string[]): boolean
  • Checks if any of the elements exist in the collection.

    Parameters

    • Rest ...keys: string[]

      The keys of the elements to check for

    Returns boolean

    true if any of the elements exist, false if none exist.

intersect

  • intersect(other: Collection<string, User>): Collection<string, User>
  • The intersect method returns a new structure containing items where the keys are present in both original structures.

    Parameters

    • other: Collection<string, User>

      The other Collection to filter against

    Returns Collection<string, User>

keys

  • keys(): IterableIterator<string>
  • Returns an iterable of keys in the map

    Returns IterableIterator<string>

last

  • last(): undefined | User
  • last(amount: number): User[]
  • Obtains the last value(s) in this collection.

    Returns undefined | User

    A single value if no amount is provided or an array of values, starting from the start if amount is negative

  • Parameters

    • amount: number

    Returns User[]

lastKey

  • lastKey(): undefined | string
  • lastKey(amount: number): string[]
  • Obtains the last key(s) in this collection.

    Returns undefined | string

    A single key if no amount is provided or an array of keys, starting from the start if amount is negative

  • Parameters

    • amount: number

    Returns string[]

map

  • map<T>(fn: (value: User, key: string, collection: Owners) => T): T[]
  • map<This, T>(fn: (value: User, key: string, collection: Owners) => T, thisArg: This): T[]
  • Maps each item to another value into an array. Identical in behavior to Array.map().

    example

    collection.map(user => user.tag);

    Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => T

      Function that produces an element of the new array, taking three arguments

        • Parameters

          Returns T

    Returns T[]

  • Type parameters

    • This

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => T
        • Parameters

          Returns T

    • thisArg: This

    Returns T[]

mapValues

  • mapValues<T>(fn: (value: User, key: string, collection: Owners) => T): Collection<string, T>
  • mapValues<This, T>(fn: (value: User, key: string, collection: Owners) => T, thisArg: This): Collection<string, T>
  • Maps each item to another value into a collection. Identical in behavior to Array.map().

    example

    collection.mapValues(user => user.tag);

    Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => T

      Function that produces an element of the new collection, taking three arguments

        • Parameters

          Returns T

    Returns Collection<string, T>

  • Type parameters

    • This

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => T
        • Parameters

          Returns T

    • thisArg: This

    Returns Collection<string, T>

partition

  • partition<K2>(fn: (value: User, key: string, collection: Owners) => key is K2): [Collection<K2, User>, Collection<Exclude<string, K2>, User>]
  • partition<V2>(fn: (value: User, key: string, collection: Owners) => value is V2): [Collection<string, V2>, Collection<string, Exclude<User, V2>>]
  • partition(fn: (value: User, key: string, collection: Owners) => boolean): [Collection<string, User>, Collection<string, User>]
  • partition<This, K2>(fn: (value: User, key: string, collection: Owners) => key is K2, thisArg: This): [Collection<K2, User>, Collection<Exclude<string, K2>, User>]
  • partition<This, V2>(fn: (value: User, key: string, collection: Owners) => value is V2, thisArg: This): [Collection<string, V2>, Collection<string, Exclude<User, V2>>]
  • partition<This>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: This): [Collection<string, User>, Collection<string, User>]
  • Partitions the collection into two collections where the first collection contains the items that passed and the second contains the items that failed.

    example

    const [big, small] = collection.partition(guild => guild.memberCount > 250);

    Type parameters

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2

      Function used to test (should return a boolean)

        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    Returns [Collection<K2, User>, Collection<Exclude<string, K2>, User>]

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    Returns [Collection<string, V2>, Collection<string, Exclude<User, V2>>]

  • Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns [Collection<string, User>, Collection<string, User>]

  • Type parameters

    • This

    • K2: string

    Parameters

    • fn: (value: User, key: string, collection: Owners) => key is K2
        • (value: User, key: string, collection: Owners): key is K2
        • Parameters

          Returns key is K2

    • thisArg: This

    Returns [Collection<K2, User>, Collection<Exclude<string, K2>, User>]

  • Type parameters

    Parameters

    • fn: (value: User, key: string, collection: Owners) => value is V2
        • (value: User, key: string, collection: Owners): value is V2
        • Parameters

          Returns value is V2

    • thisArg: This

    Returns [Collection<string, V2>, Collection<string, Exclude<User, V2>>]

  • Type parameters

    • This

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: This

    Returns [Collection<string, User>, Collection<string, User>]

random

  • random(): User
  • random(amount: number): User[]
  • Obtains unique random value(s) from this collection.

    Returns User

    A single value if no amount is provided or an array of values

  • Parameters

    • amount: number

    Returns User[]

randomKey

  • randomKey(): string
  • randomKey(amount: number): string[]
  • Obtains unique random key(s) from this collection.

    Returns string

    A single key if no amount is provided or an array

  • Parameters

    • amount: number

    Returns string[]

reduce

  • reduce<T>(fn: (accumulator: T, value: User, key: string, collection: Owners) => T, initialValue?: T): T
  • Applies a function to produce a single value. Identical in behavior to Array.reduce().

    example

    collection.reduce((acc, guild) => acc + guild.memberCount, 0);

    Type parameters

    • T

    Parameters

    • fn: (accumulator: T, value: User, key: string, collection: Owners) => T

      Function used to reduce, taking four arguments; accumulator, currentValue, currentKey, and collection

        • (accumulator: T, value: User, key: string, collection: Owners): T
        • Parameters

          • accumulator: T
          • value: User
          • key: string
          • collection: Owners

          Returns T

    • Optional initialValue: T

    Returns T

set

  • Identical to Map.set(). Sets a new element in the collection with the specified key and value.

    Parameters

    • key: string

      The key of the element to add

    • value: User

      The value of the element to add

    Returns Owners

some

  • some(fn: (value: User, key: string, collection: Owners) => boolean): boolean
  • some<T>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: T): boolean
  • Checks if there exists an item that passes a test. Identical in behavior to Array.some().

    example

    collection.some(user => user.discriminator === '0000');

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean

      Function used to test (should return a boolean)

        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: T

    Returns boolean

sort

  • sort(compareFunction?: Comparator<string, User>): Owners
  • The sort method sorts the items of a collection in place and returns it. The sort is not necessarily stable in Node 10 or older. The default sort order is according to string Unicode code points.

    example

    collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);

    Parameters

    • Optional compareFunction: Comparator<string, User>

    Returns Owners

sorted

  • sorted(compareFunction?: Comparator<string, User>): Collection<string, User>
  • The sorted method sorts the items of a collection and returns it. The sort is not necessarily stable in Node 10 or older. The default sort order is according to string Unicode code points.

    example

    collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);

    Parameters

    • Optional compareFunction: Comparator<string, User>

    Returns Collection<string, User>

sweep

  • sweep(fn: (value: User, key: string, collection: Owners) => boolean): number
  • sweep<T>(fn: (value: User, key: string, collection: Owners) => boolean, thisArg: T): number
  • Removes items that satisfy the provided filter function.

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean

      Function used to test (should return a boolean)

        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    Returns number

    The number of removed entries

  • Type parameters

    • T

    Parameters

    • fn: (value: User, key: string, collection: Owners) => boolean
        • (value: User, key: string, collection: Owners): boolean
        • Parameters

          Returns boolean

    • thisArg: T

    Returns number

tap

  • Runs a function on the collection and returns the collection.

    example

    collection .tap(coll => console.log(coll.size)) .filter(user => user.bot) .tap(coll => console.log(coll.size))

    Parameters

    • fn: (collection: Owners) => void

      Function to execute

        • Parameters

          Returns void

    Returns Owners

  • Type parameters

    • T

    Parameters

    • fn: (collection: Owners) => void
        • Parameters

          Returns void

    • thisArg: T

    Returns Owners

toJSON

  • Returns User[]

values

  • values(): IterableIterator<User>
  • Returns an iterable of values in the map

    Returns IterableIterator<User>

Generated using TypeDoc