mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
no more (#1117)
This commit is contained in:
@@ -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
|
* 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
|
* (`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).
|
* [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>
|
* [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 {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
|
* @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) {
|
find(propOrFn, value) {
|
||||||
if (typeof propOrFn === 'string') {
|
if (typeof propOrFn === 'string') {
|
||||||
if (typeof value === 'undefined') throw new Error('Value must be specified.');
|
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()) {
|
for (const item of this.values()) {
|
||||||
if (item[propOrFn] === value) return item;
|
if (item[propOrFn] === value) return item;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user