Formatting Characters in Broadcast Command Not Escaped
delbertina opened this issue ยท 4 comments
Fixed, https://snapshot.discordsrv.com for a development build
Hummm I realize the flaw in what I said now. Maybe there's a better solution to this potential issue than escaping all formatting characters.
I'm not sure how possible it is, but maybe there's a way to have a PAPI placeholder that takes in a string to be escaped. I know luckperms does this by having placeholders that accept different permission nodes within the placeholder then output whatever information based on that value passed in. So maybe it'd look something like /discord broadcast **A message about %discordsrv_escape_Some_Dudes_Username% **
Maybe it'd be more possible to do the escaping of all characters but have a way to ignore specific characters from this with say a backslash or something. For instance, /discord broadcast \*\*A message with Some_Dude_Username\*\*
turns into /discord broadcast **A message with Some\_Dude\_Username**
I'm not sure how possible it is, but maybe there's a way to have a PAPI placeholder that takes in a string to be escaped. I know luckperms does this by having placeholders that accept different permission nodes within the placeholder then output whatever information based on that value passed in. So maybe it'd look something like /discord broadcast **A message about %discordsrv_escape_Some_Dudes_Username% **
I don't see why DiscordSRV's extension should do this, the javascript extension for PAPI can do that just fine
Oh wow TIL that exists haha xD tyty <3
Edit: For anyone else trying to fix the same issue I was having, here's the PAPI Javascript files I made for this.
escaped_username.js
var username = 'example';
function escapeUsername() {
if (args.length === 1) {
username = args[0];
}
return username.replace("_", "\\_");
}
escapeUsername();
Add this to the javascript_placeholders.yml
escaped_username:
file: escaped_username.js
engine: nashorn
You can test it's working correctly by doing this command /papi parse me %javascript_escaped_username_Example_Name%
. Should output Example\_Name