【发布时间】:2022-01-02 04:02:34
【问题描述】:
我正在尝试使用 Heroku 和 Github 让我的不和谐机器人 24/7 保持在线。但每当我尝试运行我的代码时,我都会收到此错误。
2022-01-01T03:56:43.950025+00:00 app[Worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2022-01-01T03:56:43.950043+00:00 app[Worker.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2022-01-01T03:56:43.950043+00:00 app[Worker.1]: ^^^
2022-01-01T03:56:43.950044+00:00 app[Worker.1]:
2022-01-01T03:56:43.950044+00:00 app[Worker.1]: SyntaxError: Unexpected token '??='
我在两个位置放置了我的令牌,我在这些插槽中使用了 process.env.token。 第一个是我的 index.js 文件
(async () => {
for (file of functions) {
require(`./src/functions/${file}`)(client);
}
client.handleEvents(eventFiles, ".src/events");
client.handleCommands(commandFolders, "./src/commands");
client.login(process.env.token);
})();
第二个是我的 handlecommands.js 文件
module.exports = (client) => {
client.handleCommands = async(commandFolders, path) => {
client.commandArray = [];
for (folder of commandFolders) {
const commandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`../commands/${folder}/${file}`);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name, command);
client.commandArray.push(command.data.toJSON());
}
}
const rest = new REST({
version: '9'
}).setToken(process.env.token);
我该如何解决这个问题?
(快速免责声明,我没有 .env 文件,但我有一个 procfile 告诉 Heroku 该怎么做)
Worker: node index.js
【问题讨论】:
标签: github heroku discord.js