mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
no more (#1117)
This commit is contained in:
parent
3f4cbd07dd
commit
1e6abe587b
1 changed files with 2 additions and 2 deletions
|
|
@ -137,7 +137,8 @@ class Collection extends Map {
|
|||
* Searches for a single item where its specified property's value is identical to the given value
|
||||
* (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to
|
||||
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
||||
* <warn>Do not use this to obtain an item by its ID. Instead, use `collection.get(id)`. See
|
||||
* <warn>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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
|
||||
* @param {string|Function} propOrFn The property to test against, or the function to test with
|
||||
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument
|
||||
|
|
@ -150,7 +151,6 @@ class Collection extends Map {
|
|||
find(propOrFn, value) {
|
||||
if (typeof propOrFn === 'string') {
|
||||
if (typeof value === 'undefined') throw new Error('Value must be specified.');
|
||||
if (propOrFn === 'id') throw new RangeError('Don\'t use .find() with IDs. Instead, use .get(id).');
|
||||
for (const item of this.values()) {
|
||||
if (item[propOrFn] === value) return item;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue