简体   繁体   English

DiscordJS,Gulp reload bot on file save?

[英]DiscordJS, Gulp reload bot on file save?

I just started messing around with Discordjs and I'm working on just a super simple bot example, but the most annoying thing is whenever I make any changes I need to stop the bot in command line and execute the command to come back online in order for any of my code changes to take affect. 我刚刚开始搞乱Discordjs并且我正在研究一个超级简单的机器人示例,但最烦人的事情是每当我做任何更改时我都需要在命令行中停止机器人并执行命令以恢复在线状态我的任何代码更改都会生效。 Is there any way to automate this process? 有没有办法自动化这个过程? lets say I make a change to bot.js, would there be a way for something like gulp to detect this and restart the bot? 让我说我对bot.js进行了更改,是否有办法让像gulp这样的东西来检测这个并重新启动机器人?

You could use something like nodemon ( http://nodemon.io/ ). 你可以使用像nodemon( http://nodemon.io/ )这样的东西。

Install it by running: npm install -g nodemon . 通过运行安装它: npm install -g nodemon This will install it globally on your computer. 这将在您的计算机上全局安装它。 Then just run nodemon on the console instead of node myfilehere.js . 然后只需在控制台上运行nodemon而不是node myfilehere.js

Make sure the file you are running with node myfilehere.js is the same name on package.json under "main" 确保使用node myfilehere.js运行的文件与“main”下的package.json上的名称相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM