Skip to content

Commit fa2602c

Browse files
Strip color codes when sending to Discord
1 parent 0d7fe19 commit fa2602c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/com/firecontroller1847/truediscordlink/DiscordManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,17 @@ private void sendDiscordBotMessage(String content, boolean blocking, Player play
305305
api.getTextChannelById(channelId).ifPresent(channel -> {
306306
// If it exists, send a message dependent on whether or not there's a player
307307
if (player != null) {
308-
CompletableFuture<Message> future = channel.sendMessage(discordlink.getTranslation("messages.from_mc_bot_format", false,
308+
CompletableFuture<Message> future = channel.sendMessage(TrueDiscordLink.stripColorCodes(discordlink.getTranslation("messages.from_mc_bot_format", false,
309309
new String[] { "%message%", content },
310310
new String[] { "%name%" , player.getName() },
311311
new String[] { "%displayName%", player.getDisplayName() },
312312
new String[] { "%uuid%", player.getUniqueId().toString() }
313-
));
313+
)));
314314
if (blocking) {
315315
future.join();
316316
}
317317
} else {
318-
CompletableFuture<Message> future = channel.sendMessage(content);
318+
CompletableFuture<Message> future = channel.sendMessage(TrueDiscordLink.stripColorCodes(content));
319319
if (blocking) {
320320
future.join();
321321
}
@@ -343,12 +343,12 @@ private void sendDiscordWebhookMessage(String content, Player player) {
343343
// Send messages
344344
for (String url : discordlink.getConfig().getStringList("webhooks.urls")) {
345345
if (player != null) {
346-
this.makeWebhookRequest(url, discordlink.getTranslation("messages.from_mc_webhook_format", false,
346+
this.makeWebhookRequest(url, TrueDiscordLink.stripColorCodes(discordlink.getTranslation("messages.from_mc_webhook_format", false,
347347
new String[] { "%message%", content },
348348
new String[] { "%name%" , player.getName() },
349349
new String[] { "%displayName%", player.getDisplayName() },
350350
new String[] { "%uuid%", player.getUniqueId().toString() }
351-
), player.getDisplayName(), skin); // TODO: Why is the username not customizable
351+
)), TrueDiscordLink.stripColorCodes(player.getDisplayName()), skin); // TODO: Why is the username not customizable
352352
} else {
353353
this.makeWebhookRequest(url, content);
354354
}
@@ -367,7 +367,7 @@ private void makeWebhookRequest(String url, String content, String username, Str
367367
JsonObject object = new JsonObject();
368368
object.addProperty("content", content);
369369
if (username != null) {
370-
object.addProperty("username", TrueDiscordLink.stripColorCodes(username));
370+
object.addProperty("username", username);
371371
}
372372
if (skin != null) {
373373
object.addProperty("avatar_url", skin);

0 commit comments

Comments
 (0)