Skip to content

Commit

Permalink
Escape underscores in player names
Browse files Browse the repository at this point in the history
This is done to prevent player names from being
formatted as markdown when sent to discord.
Erdragh committed Jan 17, 2024
1 parent c7737fe commit 7b0cbf7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ class MinecraftHandler(private val server: MinecraftServer) : ListenerAdapter()
* @param message the String contents of the message
*/
fun sendChatToDiscord(player: ServerPlayer?, message: String) {
textChannel?.sendMessage(if (player != null) "<${player.displayName.string}> $message" else message)
textChannel?.sendMessage(if (player != null) "<${player.displayName.string.replace("_", "\\_")}> $message" else message)
?.setSuppressedNotifications(true)
?.setSuppressEmbeds(true)?.queue()
}

0 comments on commit 7b0cbf7

Please sign in to comment.