discord-needle
discord-needle copied to clipboard
🐛 Needle fails to rename thread if longer than 100 chars
Describe the bug
From Dayhawk#6969 on Discord:
Keep getting this message when trying to use /title, is this because of the update?
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
- Run
/title
with 101 valid characters - See error
- Run
/title
with 100 characters followed by any amount of slashes, backslashes, and colons - 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
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?
@nchristopher They remove them completely, "trim" was maybe not the best word to describe it
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."
To not rely on which characters Discord will strip away from the title, you mean? I think that's a reasonable idea as well.
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 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.
Oops, this was closed by #250