You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a message is deleted or updated it triggers one of two handlers, these handlers take the contents of the original message and insert it into a field within an embed. However, the character limit of these fields is smaller than the limit of normal messages.
Expected Behaviour
A message containing more than 1024 characters gets trimmed to 1024 characters within the embed.
Actual Behaviour
A message containing more than 1024 characters causes the bot to crash.
2022-03-04T11:10:05.406066+00:00 app[worker.1]: DiscordAPIError: Invalid Form Body
2022-03-04T11:10:05.406066+00:00 app[worker.1]: embeds[0].fields[0].value: Must be 1024 or fewer in length.
2022-03-04T11:10:05.406067+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
2022-03-04T11:10:05.406068+00:00 app[worker.1]: at processTicksAndRejections (node:internal/process/task_queues:96:5)
2022-03-04T11:10:05.406069+00:00 app[worker.1]: at async RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
2022-03-04T11:10:05.406070+00:00 app[worker.1]: at async TextChannel.send (/app/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15)
2022-03-04T11:10:05.406070+00:00 app[worker.1]: at async Client.sendLog (/app/build/abstracts/LogMessageDeleteHandler.js:16:13)
2022-03-04T11:10:05.406070+00:00 app[worker.1]: at async Client.handle (/app/build/event/handlers/LogMessageSingleDeleteHandler.js:11:9)
The text was updated successfully, but these errors were encountered:
Done some small testing around myself, currently I've added a simple sliceToLength static function in the StringUtils class that will slice the given string if it exceeds the passed in number. Added a value for the embed field in config.json to get the max length of the field.
You'd lose info because the content of the field is simply being cut away, there's no real extra fancy stuff going around about not slicing in the middle of a word. And another thing is that this would need to be added to every embed.addField call (at least for dynamic content like the message content in Discord itself)
Overview
When a message is deleted or updated it triggers one of two handlers, these handlers take the contents of the original message and insert it into a field within an embed. However, the character limit of these fields is smaller than the limit of normal messages.
Expected Behaviour
A message containing more than 1024 characters gets trimmed to 1024 characters within the embed.
Actual Behaviour
A message containing more than 1024 characters causes the bot to crash.
The text was updated successfully, but these errors were encountered: