小编新Ac*_*yyy的帖子

Heroku 上的 Discord 机器人抛出错误:agent ??= new https.Agent

这与我的第一个问题有关。我更新了所有代码。在我的bot.js是:

require('dotenv').config();

let ver = process.env.DISCORD_BOT;

client.once('ready', async () => {
  if (ver === 'production') {
    client.user.setActivity(`in code land`, { type: 'PLAYING' });
  } else {
    client.user.setActivity(`over ${client.guilds.cache.size} server(s)`, {
      type: 'WATCHING',
      status: 'IDLE',
    });
  }
  console.log(`Logged in as ${client.user.tag}!`);
  console.log(`the prefix is ` + prefix);
});
Run Code Online (Sandbox Code Playgroud)

Procfile:

worker: node bot.js
Run Code Online (Sandbox Code Playgroud)

package.json:

 "scripts": {
    "start": "node .",
    "test": "echo \"Error: no test specified\" && exit 1",
    "production": "NODE_ENV=production&&npm start",
    "development": "set NODE_ENV=development&&npm start"
  }
Run Code Online (Sandbox Code Playgroud)

.env: …

javascript heroku node.js discord.js

5
推荐指数
1
解决办法
524
查看次数

标签 统计

discord.js ×1

heroku ×1

javascript ×1

node.js ×1