【问题标题】:Discord.js reminder command TypeError: Expected a numberDiscord.js 提醒命令 TypeError: Expected a number
【发布时间】:2021-05-04 16:51:53
【问题描述】:

您好,我有一个不工作的提醒命令,我不断收到 TypeError: Expected a number

if(command === "remind"){
  let timeuser = args[0]
let reason = args.slice(1).join(" ")
// !remind 10m Dream Code Uploaded video

if(!timeuser) return message.reply(":x: You should enter time 10m 10s 10d")
if(!reason) return message.reply(":x: You should enter reason")

db.set(`remind.${message.author.id}`,Date.now() + ms(timeuser))
message.channel.send("ok")
const interval = setInterval(function() {


    if(Date.now() > db.fetch(`remind.${message.author.id}`)){
        db.delete(`remind.${message.author.id}`)
        message.author.send(`**Remind:**${reason}`)
        .catch(e => console.log(e))
        clearInterval(interval)
    }

},1000)
}

错误:

(node:2928) UnhandledPromiseRejectionWarning: TypeError: Expected a number
    at module.exports (C:\Users\Max\Desktop\new bot 3\node_modules\parse-ms\index.js:4:9)
    at Client.<anonymous> (C:\Users\Max\Desktop\new bot 3\index.js:1699:51)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\Max\Desktop\new bot 3\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Max\Desktop\new bot 3\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\Max\Desktop\new bot 3\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\Max\Desktop\new bot 3\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\Max\Desktop\new bot 3\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\Max\Desktop\new bot 3\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2928) 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: 1)
(node:2928) [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.

【问题讨论】:

  • 你也可以发布完整的错误信息吗?
  • 如何导入ms
  • 哪一行出错了?

标签: javascript node.js discord discord.js


【解决方案1】:

如果您想以一种简单的方式使用settimeout()

【讨论】:

    猜你喜欢
    • 2021-03-30
    • 2021-02-25
    • 2021-11-06
    • 2022-10-06
    • 2021-04-02
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 2020-03-06
    相关资源
    最近更新 更多