From 6bc0967a658f0872360f1afee07e960c6c2e4f00 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 20 Jan 2022 12:01:01 -0600 Subject: [PATCH] Fix discord formatting Signed-off-by: jolheiser --- client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 9a4bbb0..d769e8e 100644 --- a/client.go +++ b/client.go @@ -18,6 +18,12 @@ import ( "time" ) +var discordFmt = strings.NewReplacer( + "_", `\_`, + "*", `\*`, + "~", `\~`, +) + type Client struct { discord *discordgo.Session channelID string @@ -80,7 +86,7 @@ func (c *Client) sendChat(msg string) { func (c *Client) onChatMsg(msg chat.Message, _ byte, _ uuid.UUID) error { if c.discord != nil { - _, err := c.discord.ChannelMessageSend(c.channelID, msg.ClearString()) + _, err := c.discord.ChannelMessageSend(c.channelID, discordFmt.Replace(msg.ClearString())) return err } log.Info().Msg(msg.String())