Reputation:
I make discord bot via node.js on my pc and when I start server.js and add command, the new command not working I need to turn off the server.js and turn on server.js How I make a new command without restarting the server.js?
The server.js
let Discord = require("discord.js");
let client = new Discord.Client();
client.on('ready', () => {
console.log(`Hello ${client.user.tag}!`);
});
client.on("message", message => {
if (message.content === "hi"){
message.channel.send("hi")
} else if (message.content === "how are you") {
message.channel.send("I am fine")
} else if (message.content === "test") {
message.channel.send("okay")
} else if (message.content === "who made you?") {
message.channel.send("XX")
}
})
client.login("secret_key");
Upvotes: 1
Views: 223
Reputation: 1432
Thats how Node.js works. You can edit your file as you like but unless you restart your server the changes won't show up.
For this I recommend you Nodemon, which restarts your server every time file changes in the directory are detected.
Upvotes: 1