discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.44k stars 3.97k forks source link

Error Reporting for addFields value having over 1024 characters could be improved #10466

Closed jordiedh closed 1 month ago

jordiedh commented 2 months ago

Which package is this bug report for?

discord.js

Issue description

  1. Create an embed with a field value length of over 1024 (maximum length for a field value).
  2. Error message doesn't report accurately and leaves you guessing.

Description length reports an error specifically about being over 4096 characters, so I was thinking perhaps fields should do the same.

2024-08-31 17:48:39     at _ArrayValidator.handle (/app/node_modules/@sapphire/shapeshift/src/validators/ArrayValidator.ts:21:90)
2024-08-31 17:48:39     at _ArrayValidator.parse (/app/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:103:2)
2024-08-31 17:48:39     at EmbedBuilder.addFields (/app/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:116:29)
2024-08-31 17:48:39     at <anonymous> (/src/commands/stats.js:82:19)
2024-08-31 17:48:39     at Array.map (<anonymous>)
2024-08-31 17:48:39     at Object.setEmbedFields (/src/commands/stats.js:81:25)
2024-08-31 17:48:39     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-08-31 17:48:39     at Object.execute (/src/commands/stats.js:65:9)
2024-08-31 17:48:39     at MessageManager.handleCommand (/src/handlers/messageManager.js:175:17)

Code sample

// Pretty self explanitory.

const v = ''; // string of 1025+ chars.
const embed = new Discord.EmbedBuilder();
embed.addFields({ name: 'Test', value: v, inline: true });
<Channel>.send({ embeds: [embed] });

Versions

Issue priority

Low (slightly annoying)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction, GuildScheduledEvent, ThreadMember

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildModeration, GuildEmojisAndStickers, GuildIntegrations, GuildInvites, GuildVoiceStates, GuildPresences, GuildMessages, GuildMessageReactions, DirectMessages, DirectMessageReactions, MessageContent, GuildScheduledEvents, AutoModerationConfiguration, AutoModerationExecution, GuildMessagePolls, DirectMessagePolls

I have tested this issue on a development release

No response

didinele commented 1 month ago

No longer relevant as of #10448 and subsequent follow-up changes (soon). If the error is still Not Great, this issue can be re-opened.