[英]When I run a script it tells me that filter is not a function. [Discord.js]
我有一個腳本,您需要用 yes(腳本中的 da)或 no(腳本中的 nu)回答機器人,當我在 discord 上運行腳本時,它告訴我過濾器不是 function。 不得不說我是初學者。
腳本是這樣的:
module.exports = {
name: 'moneda',
description: 'mai usor de luat o decizie',
execute(message, args){
let decizii = [
"Fata",
"Spate",
]
let decizie = decizii[Math.floor(Math.random() * (decizii.length))]
message.reply(`Ti-a picat ${decizie}`);
let decizii1 = [
"Fata",
"Spate",
]
let decizie1 = decizii1[Math.floor(Math.random() * (decizii1.length))]
message.channel.send('Mai vrei sa incerci odata?').then(async (start) => {
message.channel.awaitMessage(filter, { maxMatches: 1, time: 60000, errors: ['time']}).then(async (collected) => {
if(collected.first().content === 'da') {message.channel.send(decizie1)} else if (collected.first().content === 'nu') {return}
})
})
}
}
錯誤是這樣的:
(node:8340) UnhandledPromiseRejectionWarning: ReferenceError: filter is not defined
at C:\Users\ADRIAN\Desktop\ZerOne BOT\commands\moneda.js:18:42
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated
either by throwing inside of an async function without a catch block, or by rejecting a promise which
was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the
CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:8340) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,
promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
filter
未定義,意味着您必須創建一個過濾器。
這是一個示例過濾器,針對您的問題:
let filter = m => m.author.id === message.author.id;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.