Editing files on a live bot is fast and occasionally disastrous. The habit below costs a minute and means a bad change is a thirty-second rollback instead of an evening.
What to do
- Test locally first
Run the change on your own machine against a test bot in a test server. Nearly every deployment problem is a bug you would have caught in ten seconds locally.
- Copy the files you are replacing
Before uploading, duplicate the current version.
index.jsbecomesindex.js.bak. That is your rollback, and it takes one click to use. - Upload, then restart
A running process keeps executing the code it loaded at start. Editing a file changes nothing until the restart, which catches people out when they think the change did not work.
- Watch the console through the first minute
Most failures announce themselves immediately. Sticking around for sixty seconds is the difference between finding out now and finding out from a user.
- Test the thing you changed
Not just that the bot is online. Online and broken looks identical to online and fine from the member list.
A separate application with its own token, invited only to a private server. It costs nothing, it can run on your laptop, and it means you never debug in front of an audience.
If your bot is writing to a data file when you overwrite it, you can lose the file. Stop it, change it, start it — in that order — for anything touching data.
Questions this raises
- Can I use git to deploy?
- Yes, if your bot's environment has git available. Pull, then restart. The workflow is the same; the copy step becomes a commit.
- Do I need to reinstall dependencies?
- Only if the manifest changed. Adding a library means editing
package.jsonand restarting. - Will users notice the restart?
- The bot goes offline for a few seconds. Commands sent in that window fail rather than queue.