这与我的第一个问题有关。我更新了所有代码。在我的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: …