mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Make Collection.find/exists error when using with IDs
This commit is contained in:
@@ -138,6 +138,7 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -196,6 +197,7 @@ class Collection extends Map {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
exists(prop, value) {
|
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));
|
return Boolean(this.find(prop, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user