-
-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Describe the bug
The formatting of the 'topic changed' entry for the channelUpdate event log is inconsistent depending on what the topic is set to. When no topic exists and one is set, or when you unset the topic, it's formatted as if the string length exceeds 64 characters despite there effectively being 0 characters.
To Reproduce
Steps to reproduce the behavior:
- Set or unset the topic for a channel while having the channelUpdate event log enabled for the guild.
Expected behavior
If either the old or new topic string length exceeds 64 characters, the entry should be formatted for long strings (i.e. the Events.Guilds.Logs.ChangeLongText language string). If both the old or new topic string lengths are under 64 characters (including if they are unset, meaning 0 characters), the entry should be formatted for short strings (i.e. the Events.Guilds.Logs.ChangeShortText language string).
Screenshots
Long string formatting applied correctly.

Short string formatting applied correctly.

Long string formatting incorrectly applied when topic length is 0 characters long.

Additional context
Relevant code snippet.
rtbyte/src/listeners/guilds/channels/channelUpdateLog.ts
Lines 69 to 78 in 3249f09
| if (oldChannel.topic !== channel.topic) { | |
| embed.addField(t(LanguageKeys.Events.Guilds.Logs.TopicChanged), | |
| (oldChannel.topic?.length as number < 64 && channel.topic?.length as number < 64) ? | |
| t(LanguageKeys.Events.Guilds.Logs.ChangeShortText, { before: oldChannel.topic, after: channel.topic }) : | |
| t(LanguageKeys.Events.Guilds.Logs.ChangeLongText, { | |
| before: oldChannel.topic?.length ? cutText(oldChannel.topic as string, 496) : t(LanguageKeys.Globals.None), | |
| after: channel.topic?.length ? cutText(channel.topic as string, 496) : t(LanguageKeys.Globals.None) | |
| }) | |
| ); | |
| } |