discord-needle icon indicating copy to clipboard operation
discord-needle copied to clipboard

🐛 Needle fails to rename thread if longer than 100 chars

Open MarcusOtter opened this issue 2 years ago • 6 comments

Describe the bug

From Dayhawk#6969 on Discord:

Keep getting this message when trying to use /title, is this because of the update? image

This is a previously known bug, but I've forgotten to make an issue about it. Discord has a limitation of 100 characters, and we should warn when users try to exceed that limit. We should also make sure to do the same character removal that Discord does, for example they remove /, \, and : (and probably others). Those should be removed before checking the length, and users should be warned that they have been removed.

Steps to reproduce the bug

  1. Run /title with 101 valid characters
  2. See error
  3. Run /title with 100 characters followed by any amount of slashes, backslashes, and colons
  4. Title is still set (as the total amount is 100 valid characters at the end)

Expected behavior

The bot should warn when users try to exceed the 100 character limit

MarcusOtter avatar May 26 '22 20:05 MarcusOtter

We should also make sure to do the same trimming that Discord does, for example they trim /, \, and : (and probably others).

Do they outright remove these characters from thread names, or do they remove them from the start/end?

n1ckoates avatar May 27 '22 02:05 n1ckoates

@nchristopher They remove them completely, "trim" was maybe not the best word to describe it

MarcusOtter avatar May 27 '22 08:05 MarcusOtter

I think we should try...catch the thread rename and return something along the lines of "Something went wrong while renaming the thread, titles cannot be over 100 characters."

n1ckoates avatar May 27 '22 18:05 n1ckoates

To not rely on which characters Discord will strip away from the title, you mean? I think that's a reasonable idea as well.

MarcusOtter avatar May 28 '22 23:05 MarcusOtter

I think we should try...catch the thread rename and return something along the lines of "Something went wrong while renaming the thread, titles cannot be over 100 characters."

Why do we need to try this when we have access to string.length? I've made a PR for this.

c43721 avatar Jul 14 '22 23:07 c43721

@c43721 because Discord strips the invalid characters after we try to set it in the title, so we have know way of knowing how long the length will be after the invalid chars are removed. But yeah, just setting it to 100 character limit is fine imo.

MarcusOtter avatar Jul 14 '22 23:07 MarcusOtter

Oops, this was closed by #250

MarcusOtter avatar Aug 31 '22 17:08 MarcusOtter