From d70af1f810001af1bb07e7d70f5ae88ba7b1bf8c Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 22 Nov 2020 19:13:28 +0100 Subject: [PATCH] fix(Collector): throw an error if a non-function was provided as filter --- src/structures/interfaces/Collector.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/structures/interfaces/Collector.js b/src/structures/interfaces/Collector.js index 969b3d2c38a4..e87453853df7 100644 --- a/src/structures/interfaces/Collector.js +++ b/src/structures/interfaces/Collector.js @@ -1,6 +1,7 @@ 'use strict'; const EventEmitter = require('events'); +const { TypeError } = require('../../errors'); const Collection = require('../../util/Collection'); const Util = require('../../util/Util'); @@ -74,6 +75,10 @@ class Collector extends EventEmitter { */ this._idletimeout = null; + if (typeof filter !== 'function') { + throw new TypeError('INVALID_TYPE', 'filter', 'function'); + } + this.handleCollect = this.handleCollect.bind(this); this.handleDispose = this.handleDispose.bind(this);