Options
All
  • Public
  • Public/Protected
  • All
Menu

Class News

Hierarchy

Index

Constructors

constructor

Properties

Readonly size

size: number
returns

the number of elements in the Map.

Static Readonly default

default: typeof Collection = Collection

Methods

array

  • Creates an ordered array of the values of this collection, and caches it internally. The array will only be reconstructed if an item is added to or removed from the collection, or if you change the length of the array itself. If you don't want this caching behavior, use [...collection.values()] or Array.from(collection.values()) instead.

    Returns NewsItemWithDOM[]

clear

  • clear(): void
  • Returns void

clone

concat

decrementDate

  • decrementDate(__namedParameters: { month: number; year: number }): DateYearMonth

delete

  • delete(key: string): boolean

each

equals

  • Checks if this collection shares identical key-value pairings 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

    Returns boolean

    Whether the collections have identical contents

every

  • every(fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean): boolean

fetchMonth

  • fetchMonth(__namedParameters: { month: number; year: number }, cache?: boolean, pageNumber?: number): Promise<NewsItemWithDOM[]>
  • Parameters

    • __namedParameters: { month: number; year: number }
      • month: number
      • year: number
    • Default value cache: boolean = true
    • Default value pageNumber: number = 1

    Returns Promise<NewsItemWithDOM[]>

fetchNewArticles

fetchPageContent

fetchRecent

filter

find

  • 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');

    Parameters

    • fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean

      The function to test with (should return boolean)

    Returns NewsItemWithDOM | undefined

findKey

  • findKey(fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean, thisArg?: any): string | undefined
  • 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');

    Parameters

    • fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean

      The function to test with (should return boolean)

    • Optional thisArg: any

    Returns string | undefined

first

firstKey

  • firstKey(): string | undefined
  • firstKey(amount: number): string[]

forEach

generateNewsURL

  • generateNewsURL(year: number, month: number, page?: number): string

get

  • Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.

    Parameters

    • key: string

    Returns NewsItemWithDOM | undefined

    Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.

has

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

    boolean indicating whether an element with the specified key exists or not.

keyArray

  • keyArray(): string[]
  • Creates an ordered array of the keys of this collection, and caches it internally. The array will only be reconstructed if an item is added to or removed from the collection, or if you change the length of the array itself. If you don't want this caching behavior, use [...collection.keys()] or Array.from(collection.keys()) instead.

    Returns string[]

last

lastKey

  • lastKey(): string | undefined
  • lastKey(amount: number): string[]

map

  • map<T>(fn: (value: NewsItemWithDOM, key: string, collection: this) => T): 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: NewsItemWithDOM, key: string, collection: this) => T

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

    Returns T[]

mapValues

random

randomKey

  • randomKey(): string
  • randomKey(amount: number): string[]

reduce

  • reduce<T>(fn: (accumulator: any, value: NewsItemWithDOM, key: string, collection: this) => 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: any, value: NewsItemWithDOM, key: string, collection: this) => T

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

        • (accumulator: any, value: NewsItemWithDOM, key: string, collection: this): T
        • Parameters

          Returns T

    • Optional initialValue: T

    Returns T

set

some

  • some(fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean): 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: NewsItemWithDOM, key: string, collection: this) => boolean

      Function used to test (should return a boolean)

    Returns boolean

sort

  • The sort() method sorts the elements of a collection and returns it. The sort is not necessarily stable. The default sort order is according to string Unicode code points.

    example

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

    Parameters

    Returns this

sweep

  • sweep(fn: (value: NewsItemWithDOM, key: string, collection: this) => boolean): number

tap

  • tap(fn: (collection: this) => any): this
  • 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: this) => any

      Function to execute

        • (collection: this): any
        • Parameters

          • collection: this

          Returns any

    Returns this