Skip to content

Formatting of 'topic changed' for the channelUpdate event log is inconsistent #406

@noragerdin

Description

@noragerdin

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:

  1. 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.
image

Short string formatting applied correctly.
image

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

Additional context
Relevant code snippet.

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)
})
);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ConfirmedIssues that report confirmed bugs.Meta: BugfixPRs that fix bugs or issues.Priority: LowIssues that must be fixed or PRs that must be finished and merged with low priority.Type: MaintenanceIssues and PRs related to the maintenance of a feature or function.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions