Add Discord player logging to notify when players join and leave the server #487
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Add discord player logging to notify via Discord webhook when players join and leave the server.
Adds this feature mentioned in #324
Choices
I only 1 line for joining and one line for leaving inside the pre-existing player_logging.sh loops that are currently used for broadcasting to the server. I added lines to call the pre-existing function DiscordMessage() to send a message in the loop.
I added two env variables to allow the ability to change the join and leave messages. (DISCORD_PLAYER_LEAVE_MESSAGE and DISCORD_PLAYER_JOIN_MESSAGE)
I'm quite new to docker so I could be wrong, but I believe the way I did it would work. In the dockerfile I left ${player_name} in both messages for them to be substituted later. If I understand correctly, the string "${player_name}" can not be removed if the message is changed, otherwise the substitution would fail.
I did not add anything in the message to indicate how long a player was on the server before they left.
Test instructions
I am unable to test it myself, therefore I haven't.
1.) Create a DISCORD_WEBHOOK_URL
2.) Have a player join or leave the server
3.) Check for a message in the channel for which the DISCORD_WEBHOOK_URL is set up to post to
Checklist before requesting a review