Link SETUP.md from README.md
Tweak README sentence
1.2.3
Personal Discord bot for controlling a Project Zomboid server running on Arch using the AUR package, with rcon-cli and a custom pzsh wrapper around rcon-cli (so you don't need to specify credentials every time).
There is already an excellent Discord example app that you can use as a template (the docs even assume you're using it).
I wanted to make my own to test out a few new things:
node:test
, to see how far I can get. Gist if
you're interested: tests and assertions are already pretty good, but mocking
imported modules will still need a library.*.mjs
files.--watch
.The Discord bot defines these slash commands:
Command | Description |
---|---|
/server_status |
Pings the server over RCON and lets you know if the server is up. |
/restart |
Restarts the server safely with the quit admin command. |
/pzsh <command> |
Runs an admin command over RCON. |
/pzsh
Admin CommandsAll admin commands are available for use with /pzsh
, but
some of them (e.g. help
and showoptions
) show copious output, and the
response won't fit in the Discord message that the bot will respond with, so
keep that in mind (for now, at least).
Here's a table of some useful commands, but for a full list, refer to the wiki page.
Note: mind the usage of double quotes!
Command | Description |
---|---|
/pzsh save |
Save The World™. |
/pzsh setaccesslevel "<username>" "admin" |
Make <username> an admin, so they can run admin commands in-game. |
/pzsh servermsg "<message>" |
Send a message to everyone on the server. |
This uses Node 20. nvm install
if you're using NVM.
For development, make sure to fill up .env
using template.env
. If running in
production, make sure environment variables are set up.
Commands are defined in utils/commands.mjs
. Install these with:
npm run discord:install
These are the same commands handled on POST /interactions
, with the handlers
defined in routes/interactions/post.command.mjs
.
To run the development server:
npm run dev:watch
There is a full testing suite with Node's builtin node:test
, as mentioned.
npm run test
The tests for utils/spawnCommand.mjs
rely on POSIX true
, false
, echo
,
and sh
. These will fail on a non-Unix system. I should probably fix that, but
the above are such an easy way to test exit codes, stdout, and stderr...
All that's really needed is to:
pzsh
wrapper scriptFor a specific example use case, see SETUP.md.
This project is licensed under the GNU General Public License v3.
Copyright 2023 Ian Emnace