【问题标题】:Heroku app crashing after 1 minute discord.jsHeroku 应用程序在 1 分钟后崩溃 discord.js
【发布时间】:2020-04-13 19:24:53
【问题描述】:

1 分钟后,我的应用程序在 Heroku 上崩溃了

020-04-12T15:26:27.936655+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-12T15:26:31.855012+00:00 app[web.1]: 
2020-04-12T15:26:31.855028+00:00 app[web.1]: > vicibot@1.0.0 start /app
2020-04-12T15:26:31.855030+00:00 app[web.1]: > node main.js
2020-04-12T15:26:31.855031+00:00 app[web.1]: 
2020-04-12T15:26:32.416441+00:00 app[web.1]: working
2020-04-12T15:27:29.926204+00:00 heroku[web.1]: State changed from starting to crashed

代码:

const discord = require(`discord.js`);
const bot = new discord.Client();
const port = process.env.PORT || 80
const token= '*Token*';
const prefix = 'vici!';
var servers = {};

bot.on('ready', () =>{
    console.log('dziala');
})

bot.on('message', msg=>{
  let arg = msg.content.substring(prefix.length).split(" ");
    switch(arg[0]){
        case 'ping':
            msg.channel.send('pong!');
            break;
}}
bot.login(token);

简单的 Discord 机器人来回答命令

知道怎么解决吗?

【问题讨论】:

  • 为什么你的应用这样做?它是否绑定到 Heroku 告诉它的端口?
  • 分享你的代码
  • 如果您不向我们展示您的代码,我们将无能为力。请阅读How to Ask
  • 已编辑。给您添麻烦了

标签: node.js heroku


【解决方案1】:

好的,我知道那里发生了什么。 你需要添加

var express = require('express');
var app = express();

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Our app is running on port ${ PORT }`);
});```

into code

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2018-07-09
    • 2021-11-10
    • 2015-10-11
    • 1970-01-01
    • 2019-02-06
    相关资源
    最近更新 更多