mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
Make Collection.find/exists error when using with IDs
This commit is contained in:
parent
af5e07fb33
commit
ee3a03f707
1 changed files with 2 additions and 0 deletions
|
|
@ -138,6 +138,7 @@ 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;
|
||||
}
|
||||
|
|
@ -196,6 +197,7 @@ class Collection extends Map {
|
|||
* }
|
||||
*/
|
||||
exists(prop, value) {
|
||||
if (prop === 'id') throw new RangeError('Don\'t use .find() with IDs. Instead, use .get(id).');
|
||||
return Boolean(this.find(prop, value));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue