{"record":{"id":"f68fc1864bafcd1a","repo":"discordjs/discord.js","slug":"invalidtype-f68fc1","errorCode":"InvalidType","errorMessage":"Supplied ${name} is not a${an ? 'n' : ''} ${expected}.","messagePattern":"Supplied (.+?) is not a(.+?) (.+?)\\.","errorType":"error_code","errorClass":"DiscordjsTypeError","httpStatus":null,"severity":"error","filePath":"packages/discord.js/src/structures/interfaces/Collector.js","lineNumber":101,"sourceCode":"\n    /**\n     * Timeout for cleanup due to inactivity\n     *\n     * @type {?Timeout}\n     * @private\n     */\n    this._idletimeout = null;\n\n    /**\n     * The reason the collector ended\n     *\n     * @type {?string}\n     * @private\n     */\n    this._endReason = null;\n\n    if (typeof this.filter !== 'function') {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options.filter', 'function');\n    }\n\n    this.handleCollect = this.handleCollect.bind(this);\n    this.handleDispose = this.handleDispose.bind(this);\n\n    if (options.time) this._timeout = setTimeout(() => this.stop('time'), options.time).unref();\n    if (options.idle) this._idletimeout = setTimeout(() => this.stop('idle'), options.idle).unref();\n\n    /**\n     * The timestamp at which this collector last collected an item\n     *\n     * @type {?number}\n     */\n    this.lastCollectedTimestamp = null;\n  }\n\n  /**\n   * The Date at which this collector last collected an item","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/structures/interfaces/Collector.js#L83-L119","documentation":"Generic typed-argument validation from DiscordjsTypeError: a constructor option or argument was passed with the wrong JavaScript type. In Collector's constructor the specific throw is options.filter not being a function, but the same code template is used across the library for any `is not a <expected>` mismatch.","triggerScenarios":"Calling createMessageCollector / createInteractionCollector / new Collector(...) with options.filter undefined, a truthy non-function (e.g. an object like { member: ... } passed where a predicate is expected), a misspelled property (filters instead of filter), or a filter accidentally overwritten by a boolean/string.","commonSituations":"Refactoring a filter into a config object and forgetting to wrap it in a function; copying code where `filter:` got minified/renamed; passing await results (a collection) instead of a predicate; TypeScript users bypassing types with `as any`.","solutions":["Pass a function to options.filter, e.g. filter: (msg) => msg.author.id === userId.","If your condition data is an object, wrap it: filter: makePredicate(myConfig) instead of filter: myConfig.","Check property spelling and that no earlier assignment replaced filter with a non-function.","In TypeScript, rely on CollectorOptions typing; remove `any` casts so the compiler flags non-function filters."],"exampleFix":"// before\nconst collector = channel.createMessageCollector({ filter: { author: userId } });\n\n// after\nconst collector = channel.createMessageCollector({ filter: (msg) => msg.author.id === userId });","handlingStrategy":"validation","validationCode":"if (typeof options?.filter !== 'function') {\n  throw new TypeError('options.filter must be a function');\n}","typeGuard":"function hasValidFilter(options) {\n  return typeof options?.filter === 'function';\n}","tryCatchPattern":"let collector;\ntry {\n  collector = channel.createMessageCollector({ filter: (m) => m.author.id === userId });\n} catch (err) {\n  if (err?.name === 'TypeError' && /InvalidType/.test(err.message)) {\n    console.error('filter must be a function');\n  } else throw err;\n}","preventionTips":["Always pass filter as an arrow function, never raw config objects.","Use TypeScript CollectorOptions typing and avoid `any` casts.","Spell filter (singular) exactly as the API expects.","Unit-test collector setup paths to fail fast on bad options."],"tags":["validation","typeerror","collector","developer-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}