From 7365f403006eeb28ab10f03cbf85416272678ef7 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Tue, 8 Dec 2020 20:11:44 +0100 Subject: [PATCH] fix(Collector): throw an error if a non-function was provided as filter (#5034) --- 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 969b3d2c3..e87453853 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);