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

Player spawn Discord notification doesn't work #696

Open
NorskNoobing opened this issue Jul 16, 2024 · 2 comments
Open

Player spawn Discord notification doesn't work #696

NorskNoobing opened this issue Jul 16, 2024 · 2 comments

Comments

@NorskNoobing
Copy link

I set up the Discord player spawn notification from the log filter using the steps in the readme. I translated it into my composefile, but it doesn't seem to work. No error is logged in the container logs, and I don't get any messages on Discord. I tested the server start notification via Discord, and it worked properly.

Are there any syntax issues? How could I troubleshoot this? Is there another logfile for these types of logs?

Here's how the relevant env-vars look:

environment:
  - DISCORD_WEBHOOK=REDACTED
  - VALHEIM_LOG_FILTER_CONTAINS_Spawned="Got character ZDOID from"
  - 'ON_VALHEIM_LOG_FILTER_CONTAINS_Spawned={ read l; l=$${l//*ZDOID from /}; l=$${l// :*/}; msg="Player $$l spawned into the world"; curl -sfSL -X POST -H "Content-Type: application/json" -d "{\"username\":\"Valheim\",\"content\":\"$$msg\"}" "$$DISCORD_WEBHOOK"; }'
@lucasgmarques
Copy link

lucasgmarques commented Sep 25, 2024

I setup an env file for my server and and the notification works properly.

Try this:

environment:
  - DISCORD_WEBHOOK=REDACTED
  - VALHEIM_LOG_FILTER_CONTAINS_Spawned="Got character ZDOID from"
  - ON_VALHEIM_LOG_FILTER_CONTAINS_Spawned='{ read l; l=$${l//*ZDOID from /}; l=$${l// :*/}; msg="Player $$l spawned into the world"; curl -sfSL -X POST -H "Content-Type: application/json" -d "{\"username\":\"Valheim\",\"content\":\"$$msg\"}" "$$DISCORD_WEBHOOK"; }'

@NorskNoobing
Copy link
Author

I copied your exact settings, but when I ran docker compose up -d I got the following error:

> docker compose up -d valheim-server
services.valheim-server.environment.[14]: unexpected type map[string]interface {}

This seems to be because the composefile doesn't interpret the whole thing as a string, which is weird because it doesn't have any single quotes ' inside the string. Only the purple part is interpreted as a string:
image

Therefore I tried putting the whole env-var inside of single quotes, instead of just the value, and that doesn't throw any error. However I still don't get any message when I join the server.

environment:
  - DISCORD_WEBHOOK=REDACTED
  - VALHEIM_LOG_FILTER_CONTAINS_Spawned="Got character ZDOID from"
  - 'ON_VALHEIM_LOG_FILTER_CONTAINS_Spawned={ read l; l=$${l//*ZDOID from /}; l=$${l// :*/}; msg="Player $$l spawned into the world"; curl -sfSL -X POST -H "Content-Type: application/json" -d "{\"username\":\"Valheim\",\"content\":\"$$msg\"}" "$$DISCORD_WEBHOOK"; }'

image

I also looked into the container logs, just to make sure that the log event actually happens when I join, and it seems to be fine:

2024-10-10T10:07:36.466498350Z Oct 10 12:07:36 supervisord: valheim-server 10/10/2024 12:07:36: Got character ZDOID from ${CHARACTER_NAME} : ${SOME_PLAYER_ID_?}

Is there any logs for the discord message/log filter triggers that I can look into for troubleshooting? Does it work for you when using the exact same env-vars that I used in the example above?

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

No branches or pull requests

2 participants