Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Discord player logging to notify when players join and leave the server #487

Merged
merged 7 commits into from
Mar 5, 2024
Merged

Add Discord player logging to notify when players join and leave the server #487

merged 7 commits into from
Mar 5, 2024

Conversation

xHyperElectric
Copy link
Contributor

@xHyperElectric xHyperElectric commented Mar 3, 2024

Context

Add discord player logging to notify via Discord webhook when players join and leave the server.

Adds this feature mentioned in #324

Script for notifying the public join/leave channel and broadcasting via RCON when a player joins or leaves: image

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

  • I have performed a self-review of my code
  • I've added documentation about this change to the README.
  • I've not introduced breaking changes.

@xHyperElectric
Copy link
Contributor Author

I'm not familiar with docusaurus but it seems the check failed because I didn't properly escape the ${player_name} in the docusaurus docs.

Error: Docusaurus server-side rendering could not render static page with path /getting-started/configuration/server-settings because of error: player_name is not defined

@thijsvanloef thijsvanloef merged commit 133a713 into thijsvanloef:main Mar 5, 2024
10 checks passed
@xHyperElectric xHyperElectric deleted the Discord-Player-Logging branch March 5, 2024 16:57
MusclePr pushed a commit to MusclePr/palworld-server-docker that referenced this pull request Jun 19, 2024
…r-Logging

Add Discord player logging to notify when players join and leave the server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants