nwesterhausen / valheim-discordconnector

A plugin to connect a Valheim server to a discord webhook.
https://discord-connector.valheim.games.nwest.one/
MIT License
27 stars 13 forks source link

Pass @'s to discord in a way that can be used to trigger discord tags #252

Closed azegoca closed 4 months ago

azegoca commented 6 months ago

I would like to have the ability to use @here or @<role|user> in-game shout to trigger that tag in discord. I think if this is possible, there would also need to be an enable boolean of the feature, and maybe even an ACL for allow/deny roles, to protect from spam/annoyance.

vavavr00m commented 5 months ago

Upvote! I was just contacted by one of the server admin of our Discord server because of the @here spamming even though the role/category was already limited to specific users since Admins and Server Owners can't be removed from any channel/category, they get tagged unnecessarily by @here. DiscordConnector can't still tag a role with the 2.2.2 update.

nwesterhausen commented 5 months ago

So as it is right now, any correctly formatted @role_id, @user_id or @here will be tagged correctly on discord. The issue is it is based on the id of the user or role and not the name of either. See allowed-mentions object which is empty by default (and allows any).

Regarding the @here spam, it would be easy to add a toggle in the DiscordConnector configuration to specifically disallow @here.

For tagging a specific role or user, the easiest way might be using one of the custom %VARN% variables since an ID can be long and ugly, that way your messages can include a mention with a varaible inclusion instead of the mention syntax: VAR_1=<@102309592> then JOIN_MESSAGE=%PLAYER_NAME% joined! %VAR1 (an example which isn't formatted correctly, but gets the point across).

For players to be able to tag specific roles or users on their own by name we would have to have a dictionary of some kind to transform the message.. A bit more complicated.

vavavr00m commented 4 months ago

I searched and saw that to get the ID of the role, one must write \@rolename. I got a <@&0000000000000000000> format. If I'm understanding your message, it would mean the ampersand along with the angle brackets will be included to properly tag the role, yeah?

nwesterhausen commented 4 months ago

Yes that matches my understanding but I haven’t had a chance to test it yet

nwesterhausen commented 4 months ago

I did test by grabbing my username, using the <@xxxx> number and when that gets sent via the webhook, it gets parsed into a mention: image

With a role, using the <@&xxxx> number also gets the same: image

What also works (because no restrictions are put in place by default): image

nwesterhausen commented 4 months ago

Based on some simple testing and how annoying pings are for @here and @everyone, I'm going to have those disabled by default, but able to be set as allowed.

Also will allow setting more settings like allowing specific users or roles only, because some users may abuse the ability to ping people this way.