Repository navigation
Closed
Labels
bugSomething isn't workingpriority: normalvalidThis issue/PR is validated and ready to be picked. This auto adds items to TJ project board.
Description
Problem
Right now we have so many questions (70) that the message for #active_questions is too long for Discord (>2000 characters). Discord prevents the edit and the action fails:
tjbot-develop_1 | 2022-08-25T11:19:46.304526000Z java.lang.IllegalStateException: Cannot build a Message with more than 2000 characters. Please limit your input.
tjbot-develop_1 | 2022-08-25T11:19:46.304816000Z at net.dv8tion.jda.api.MessageBuilder.build(MessageBuilder.java:1022) ~[JDA-5.0.0-alpha.9.jar:5.0.0-alpha.9]
tjbot-develop_1 | 2022-08-25T11:19:46.305012000Z at org.togetherjava.tjbot.commands.help.HelpThreadOverviewUpdater.updateOverview(HelpThreadOverviewUpdater.java:139) ~[classes/:?]
tjbot-develop_1 | 2022-08-25T11:19:46.305217000Z at org.togetherjava.tjbot.commands.help.HelpThreadOverviewUpdater.updateOverviewForGuild(HelpThreadOverviewUpdater.java:105) ~[classes/:?]
tjbot-develop_1 | 2022-08-25T11:19:46.305422000Z at net.dv8tion.jda.internal.utils.cache.AbstractCacheView.forEach(AbstractCacheView.java:101) ~[JDA-5.0.0-alpha.9.jar:5.0.0-alpha.9]
tjbot-develop_1 | 2022-08-25T11:19:46.305614000Z at org.togetherjava.tjbot.commands.help.HelpThreadOverviewUpdater.runRoutine(HelpThreadOverviewUpdater.java:69) ~[classes/:?]
tjbot-develop_1 | 2022-08-25T11:19:46.306132000Z at org.togetherjava.tjbot.commands.system.BotCore.lambda$scheduleRoutines$7(BotCore.java:172) ~[classes/:?]
tjbot-develop_1 | 2022-08-25T11:19:46.306356000Z at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:19:46.306588000Z at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:19:46.306935000Z at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:19:46.307183000Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:19:46.307430000Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:19:46.307664000Z at java.lang.Thread.run(Thread.java:833) ~[?:?]
tjbot-develop_1 | 2022-08-25T11:20:46.302391000Z 11:20:46.294 [pool-3-thread-1] ERROR org.togetherjava.tjbot.commands.system.BotCore - Unknown error in routine HelpThreadOverviewUpdate
As a result, our question overview rots and gets no updates anymore.
Workaround
The only way to work around this is by actively closing threads until its below the limit again.
On the good note, the system heals itself once the message is small enough again.
Approach
We have to find a solution to this problem. Unfortunately, I can not think of a very simple one.
Possibilities:
- Divide the question into multiple messages, disadvantages: Makes finding and editing the question more cumbersome
- See if we can use embeds to bypass the limit (one embed per category?) - the original reason we did not use embeds is because links in embeds could not be clicked on mobile (Android). The latest update to Android might have fixed that though.
Reacted by Marko Radosavljević
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingpriority: normalvalidThis issue/PR is validated and ready to be picked. This auto adds items to TJ project board.
Activity
github-actions commentedon Sep 25, 2022
This issue is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days.
Zabuzard commentedon Sep 26, 2022
not critical anymore, due to the getting rid of the bug that caused questions to pile up in the first place. still important to fix for our growing plans though
Gyoo commentedon Oct 5, 2022
I had a quick glance at the code, currently the existing Overview message is always edited. Is there any reason for that ? Can't we just wipe the existing message and create a new one for each update ? Only downside I can see is that it'll generate a lot of unread messages, but you'll have the same issue if you add an extra message from time to time if the first one is too long.
Zabuzard commentedon Oct 5, 2022
@Gyoo that wouldnt fix the issue. JDA doesnt allow long messages. Regardless of initial post or edit.
Tais993 commentedon Oct 5, 2022
I'm too lazy to create a bot that sends a message with a channel mention in it, so here a test to check or channel mentions work in embeds on phone yet:
<#895717328359153664>
Gyoo commentedon Oct 5, 2022
Sorry, I think my previous message was unclear.
My idea to fix this issue would be to delete the existing message and create one/multiple new messages (depending on the number of active questions), instead of always editing the existing message.
Message edition works fine most of the time in this case, but it suddenly becomes really cumbersome when you have to manage multiple editions at a time. That's why I think the delete/create workflow makes it easier to manage. But I can see one downside, as I explained in my previous message, that may be a lot of unread messages to check if you're a notification freak like me :)
I hope I made this clearer
Tais993 commentedon Oct 6, 2022
After testing, seems Discord mobile finally supports the ability to click on channel mentions in embeds.
So my proposed solution is to simply replace it with an embed.
This allows 4096 characters, instead of the current 2000. If we really need it, we can make it so the bot sends multiple embeds.
But do we need that at the moment?
Zabuzard commentedon Oct 6, 2022
one embed is fine. Its unlikely we run into the limit anytime soon. we are not even running into the 2k limit anymore (but barely during very high activity).
Replaced overview message to embed (#611)