使用node.js运行代码会出现错误,但没有节点则可以正常运行

时间:2019-06-23 08:36:47

标签: javascript node.js discord.js

我正在使用Visual Studio代码。当我正常运行我的代码时(CTRL + ALT + N),它可以正常运行。但是,当我在Windows Powershell中使用node.js运行它时,它给了我一个错误。 这是我的代码:

if (message.content.startsWith(`${prefix}role`)) {
        const filter = m => m.author.id === message.author.id;
        message.delete(1);
        message.reply("Choose title (message will expire after 10 seconds")
        .then((r) => {
            sleep(1)
            botlastMSG = message.channel.lastMessageID
            r.delete(10000)
        })
        message.channel.awaitMessages(filter, {max: 1, time: 10000, errors: ['time']}).then(collected => {
            var response = collected.first().content
            var respMsG = message.channel.lastMessageID
          message.channel.fetchMessage(botlastMSG).then(msg => msg.delete(1));  


          if (response == "cancel") return message.channel.send("Cancelled!").then(r => r.delete(2000))
          newArr.push(response)
          show = 1  
          message.channel.fetchMessage(respMsG).then(msg => msg.delete(1))//deletes response          
        }).catch(err =>{message.reply("Time has expired!").then(r => r.delete(3000))})  

        while (show == 0) {
            await sleep(1)
        }

这是我在节点上运行时遇到的错误:

(node:23652) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at item.request.gen.end (C:\Users\Adam\Desktop\botd\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15)
    at then (C:\Users\Adam\Desktop\botd\node_modules\snekfetch\src\index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:23652) 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(). (rejection id: 2)
(node:23652) [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.

0 个答案:

没有答案
相关问题