Discord.js机器人没有上线托管 Heroku



我在heroku上托管我的机器人程序时遇到问题。我已经部署了我的机器人,它工作了大约30个小时。然后我关闭了大约10个小时,并对我的代码进行了一些重大更改。但是,config.json和Procfile文件保持不变。我已经尝试了很多事情,比如重新启动工人。1 dyno。我还删除了我的应用程序并重新创建了它。有人说要将worker: node index.js更改为worker: npm startservice: npm start。两者都不起作用。

程序文件:service: npm start

Config.json:

{
"mongoPath": "mongodb://localhost:27017",
"useNewUrlParser": "true",
"prefix": "$",
"token": "MY SUPER SECRET TOKEN"
}

Package.json:

{
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" $$ exit 1",
"start": "node index.js"
},
"repository": {
"type": "git",
"url": " "
},
"keywords": [],
"author": "Joel",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"discord.js": "^12.4.1",
"discord.js-tictactoe": "^1.0.2",
"humanize-duration": "^3.24.0",
"mongoose": "^5.10.11",
"ms": "^2.1.2",
"opusscript": "0.0.7",
"request": "^2.88.2",
"wokcommands": "^1.0.1",
"ytdl-core": "^4.0.0"
},
"engines": {
"node": "14.4.0",
"npm": "6.14.5"
}
}

Index.js

//Packages
const Discord = require('discord.js');
const ms = require('ms');
const fs = require('fs');
const ytdl = require('ytdl-core');
const cheerio = require('cheerio');
const request = require('request');
const Duration = require('humanize-duration');
const config = require('./config.json');

//clients
const bot = new Discord.Client();
bot.commands = new Discord.Collection();
const Embed = new Discord.MessageEmbed();
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}

bot.on('ready', () => {
console.log('ACTIVE!');
});
bot.on('message', (message) => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
let args = message.content.substring(config.prefix.length).split(' ');
const command = args.shift().toLowerCase();
if (command === 'ban') {
bot.commands.get('pp').execute(message, args, bot);
} else if (command === 'members') {
bot.commands.get('pp').execute(message, args, bot);
} else if (command === 'cls') {
bot.commands.get('cls').execute(message, args, bot);
} else if (command === 'ctc') {
bot.commands.get('ctc').execute(message, args, bot);
} else if (command === 'cvc') {
bot.commands.get('cvc').execute(message, args, bot);
} else if (command === 'echo') {
bot.commands.get('echo').execute(message, args, bot);
} else if (command === 'g') {
bot.commands.get('g').execute(message, args, bot);
} else if (command === 'gg') {
bot.commands.get('gg').execute(message, args, bot, Discord, Duration);
} else if (command === 'help') {
bot.commands.get('help').execute(message, args, Discord, Duration);
} else if (command === 'i') {
bot.commands.get('i').execute(message, args, cheerio);
} else if (command === 'iq') {
bot.commands.get('iq').execute(message, args, bot);
} else if (command === 'kick') {
bot.commands.get('kick').execute(message, args, bot);
} else if (command === 'members') {
bot.commands.get('members').execute(message, args, bot);
} else if (command === 'pick') {
bot.commands.get('pick').execute(message, args, bot, Discord);
} else if (command === 'ping') {
bot.commands.get('ping').execute(message, args, bot);
} else if (command === 'pl') {
bot.commands.get('pl').execute(message, args, bot);
} else if (command === 'pm') {
bot.commands.get('pm').execute(message, args, bot);
} else if (command === 'poll') {
bot.commands.get('poll').execute(message, args, Embed);
} else if (command === 'pp') {
bot.commands.get('pp').execute(message, args, bot);
} else if (command === 'spam') {
bot.commands.get('spam').execute(message, args, bot);
} else if (command === 'status') {
bot.commands.get('status').execute(message, args, bot);
} 
});
bot.login(config.token);

日志:

2020-11-04T22:11:10.210494+00:00 heroku[worker.1]: Starting process with command `npm start`
2020-11-04T22:11:10.927608+00:00 heroku[worker.1]: State changed from starting to up
2020-11-04T22:11:13.224071+00:00 app[worker.1]:
2020-11-04T22:11:13.224087+00:00 app[worker.1]: > discord-bot@1.0.0 start /app
2020-11-04T22:11:13.224087+00:00 app[worker.1]: > node index.js
2020-11-04T22:11:13.224088+00:00 app[worker.1]:
2020-11-04T22:11:14.157433+00:00 app[worker.1]: ACTIVE!

如果有人能帮我,我将不胜感激。提前感谢!

对不起,我修复了它。我重新生成了令牌,它起作用了。