diff --git a/internal/ui/chat/message_input.go b/internal/ui/chat/message_input.go index 2cf70b6..792534f 100644 --- a/internal/ui/chat/message_input.go +++ b/internal/ui/chat/message_input.go @@ -199,7 +199,7 @@ func (mi *messageInput) send() { } }() - text = processText(mi.chatView.state, selected, []byte(text)) + text = mi.processText(selected, []byte(text)) if mi.edit { m, err := mi.chatView.messagesList.selectedMessage() @@ -231,7 +231,7 @@ func (mi *messageInput) send() { mi.chatView.messagesList.ScrollToEnd() } -func processText(state *ningen.State, channel *discord.Channel, src []byte) string { +func (mi *messageInput) processText(channel *discord.Channel, src []byte) string { // Fast path: no mentions to expand. if bytes.IndexByte(src, '@') == -1 { return string(src) @@ -239,7 +239,7 @@ func processText(state *ningen.State, channel *discord.Channel, src []byte) stri // Fast path: no back ticks (code blocks), so expand mentions directly. if bytes.IndexByte(src, '`') == -1 { - return string(expandMentions(state, channel, src)) + return string(mi.expandMentions(channel, src)) } var ( @@ -265,13 +265,14 @@ func processText(state *ningen.State, channel *discord.Channel, src []byte) stri }) for _, rng := range ranges { - src = slices.Replace(src, rng[0], rng[1], expandMentions(state, channel, src[rng[0]:rng[1]])...) + src = slices.Replace(src, rng[0], rng[1], mi.expandMentions(channel, src[rng[0]:rng[1]])...) } return string(src) } -func expandMentions(state *ningen.State, c *discord.Channel, src []byte) []byte { +func (mi *messageInput) expandMentions(c *discord.Channel, src []byte) []byte { + state := mi.chatView.state return mentionRegex.ReplaceAllFunc(src, func(input []byte) []byte { output := input name := string(input[1:]) diff --git a/internal/ui/chat/messages_list.go b/internal/ui/chat/messages_list.go index 206070b..f1e3f03 100644 --- a/internal/ui/chat/messages_list.go +++ b/internal/ui/chat/messages_list.go @@ -665,11 +665,6 @@ func (ml *messagesList) delete() { if msg.GuildID.IsValid() { me, _ := ml.chatView.state.Cabinet.Me() - if err != nil { - slog.Error("failed to get client user (me)", "err", err) - return - } - if msg.Author.ID != me.ID && !ml.chatView.state.HasPermissions(msg.ChannelID, discord.PermissionManageMessages) { slog.Error("failed to delete message; missing relevant permissions", "channel_id", msg.ChannelID, "message_id", msg.ID) return