garagepoort / staffplusplus-discord

1 stars 1 forks source link

Allow variables outside of fields #2

Closed coralpapa closed 2 years ago

coralpapa commented 2 years ago

I am customizing the templates provided and I want to use an event variable in the url but when i trigger the event the variable goes from:

${detectedEvent.player.getUUID()}

to %24%7BdetectedEvent.player.getUUID()%7D

Think it would be really handy to be able to do uuid or name of player there to point to either your own site to their pofile or a site like namemc.com

garagepoort commented 2 years ago

@coralpapa can you give the entire example in which it isn't working

coralpapa commented 2 years ago

This is what i am currently using:

        "title": "Chat message detection from ${detectedEvent.player.name}",
        "url": "https://namemc.com/profile/${detectedEvent.player.getUUID()}",
        "color": "16601379",
        "timestamp": "${timestamp}",

        but link shows up 

        https://namemc.com/profile/$%7BdetectedEvent.player.getUUID()%7D
garagepoort commented 2 years ago

Hey @coralpapa

It just seems the expression is wrong. It should be ${detectedEvent.player.uniqueId}

coralpapa commented 2 years ago

ah, sorry i thought .getUUID() was the method for the player object, seems it was .getUniqueId() console did throw any error so I figured it was just decoding it for url purposes. sorry about the run around

garagepoort commented 2 years ago

No problem. There is a small warning message shown if the expression is invalid. But it's easily missed:

[13:54:44] [Server thread/WARN]: [StaffPlusPlusDiscord] Invalid expression: [detectedEvent.player.getUUID()]