#discord.js

13588 messages · Page 14 of 14 (latest)

white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

When iterating over fields in a ModalSubmitInteraction, the following TypeScript code can potentially throw an error:

// ctx is a ModalSubmitInteraction
for (const field of ctx.fields.components.filter((c) => c.type === ComponentType.Label)) {
  const component = field.component;
  if (component.type === ComponentType.FileUpload) {
    const fieldAttachments = component.attachments.values().toArray() || [];
 ...
white prawnBOT
#

Which application or package is this feature request for?

discord.js

Feature

Effectively, we have to ensure you can get things working via the pattern shown in the 2nd example of this section https://github.com/discordjs/discord.js/tree/main/packages/ws#specify-worker_threads

This will require some internal changes, as right now every client spawns its own WebSocketManager. Total feature parity can totally be accomplished, we just have to think a bit about what & how we provide ...

#
white prawnBOT
white prawnBOT
#

Are you truncating it the stack trace? Have you set it up improperly in Sentry? It only gives 2 lines and nothing about discord.js, which is useless:

TypeError: undefined is not an object (evaluating 'comp.attachments.values')
    at handleFormSubmit (/app/src/utils/ticketCreate.ts:161:27)
    at processTicksAndRejections (native:7:39)

Regardless, managed to find a reproduction:

  1. Create a modal with an optional file upload component
  2. Submit it
  3. Check for the label component's...
white prawnBOT
white prawnBOT
white prawnBOT
#

Summary

Makes FileUploadModalData.attachments optional to match runtime behavior.

Problem

When a modal has an optional FileUpload component and the user doesn't upload a file, component.attachments is undefined at runtime. However, the TypeScript types marked it as required, causing no compile-time warning but runtime errors when accessing the property.

Solution

Add ? to the attachments field in FileUploadModalData interface:

// Before
attachments: R...
white prawnBOT
#

Summary

  • Makes the attachments property optional in FileUploadModalData interface
  • Aligns TypeScript types with runtime behavior where attachments may be undefined
  • Adds type test to verify the optional property behavior

Issue

Fixes #11359

Test Plan

  • [x] Added type test in typings/index.test-d.ts to verify attachments can be undefined
  • [x] All existing tests pass (pnpm run test --filter=discord.js)
  • [x] Type definitions are valid (tsd passes)

Changes

  • `pack...
white prawnBOT
#

For instance, passing an empty string to RoleManager#fetch() will now make a request to the Get Guild Roles endpoint, but through the Get Guild Role path internally.

I think I understand so the original idea was that you would query the empty string with Discord but your saying since the endpoint is /guild_id/roles/role_id if you pass an empty string it would result in /guild_id/roles/ which is a different endpoint.

Side Note: This makes me think the REST package shouldn't al...

white prawnBOT
white prawnBOT
#

Summary

This PR fixes issue #11359 by making the attachments property in FileUploadModalData optional to match the runtime behavior.

Changes

  • Modified FileUploadModalData interface: Changed attachments: ReadonlyCollection to attachments?: ReadonlyCollection in packages/discord.js/typings/index.d.ts
  • Added TypeScript tests: Added test cases to verify the fix works correctly in packages/discord.js/typings/index.test-d.ts

Problem

The issue was that the TypeS...

#

Hi! I've created a fix for this issue.

Problem: The TypeScript typings for FileUploadModalData indicated that attachments was always present, but at runtime it could be undefined when there are no attachments, causing runtime errors.

Solution: Made the attachments property optional in the TypeScript definitions to match the actual runtime behavior.

PR: #11367

The fix allows developers to use optional chaining (component.attachments?.values()) without TypeScript comp...

#

Resolved CodeRabbit AI feedback

Implemented the suggested improvements:

  1. Added explicit type assertions: Added expectAssignable(...) calls for both test cases to make type verification more explicit and consistent with existing test patterns.

  2. Added proper type parameters: Changed new Collection() to new Collection() to match the expected interface exactly.

These changes improve test quality and maintain consistency with the existing codebase patterns.

white prawnBOT
white prawnBOT
#

I'm thinking maybe it would make sense to throw a Discord like error for empty strings manually (like you would get if you passed any other non-snowflake string to the API because we can't actually pass the empty string because it would be interpreted as a different endpoint).

We could throw an error in resolveId() if the input is a primitive value that is not a non-empty string

white prawnBOT
#

Which application or package is this feature request for?

discord.js

Feature

support for async sweeper functions ala

const client: WayaClient = new WayaClient({
    intents: [
        // ...
    ],
    sweepers: {
        ...Options.DefaultSweeperSettings,
        messages: {
            interval: 24 * 60 * 60,
            filter: async () => {
                // Fetch data
                const guilddbs = await pgdb
                    .selectFrom("guilds")
                 ...
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Need to fix tests, but other than that LGTM

What's the best way to proceed? I've realized that for this change to work correctly, we need to modify type APIInteractionDataResolvedChannel in the discord-api-types. This type uses all channel types, but we need only option allowed.

  1. Should I open an PR in the discord-api-types repository and link to it here?
  2. Or would it be better to implement a temporary workaround within this PR to avoid blocking the changes?
  3. Or perhaps I'...
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

Steps to reproduces

  1. Initialize client
await this.client.login(token);
console.log(this.client.user) // Clearly see the `user` object
  1. Add roles to a member
const guild = await this.discordClient.guilds.fetch(guildId);
const member = await guild.members.fetch(userId);

// Work like a charm!
// for (let role of uniqueRoles) {
//     await member.roles.add(role);
// }

// Did work! Error provide ...
white prawnBOT
white prawnBOT
white prawnBOT
#

When a modal has an optional FileUpload component and the user doesn't upload a file, component.attachments is undefined at runtime. However, the TypeScript types marked it as required, causing no compile-time warning but runtime errors when accessing the property.

If Discord sends an empty array, we should be setting components.attachments to an empty collection. Can you verify if that behaviour?

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

The issue started at 16:16 and continues to this day. Upon reloading and restarting, the code fails to connect, even though it was working normally beforehand and no code modifications were made. Please investigate the cause.

Code sample


Versions

discordjs lastet version,
nodejs v20.19.0

Issue priority

High (immediate attention needed)

Which partials do you have configu...

white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

To reproduce:
Run this command on any Linux operating system with 'npm' and 'node' installed: sudo npm install [email protected]
The output will say:

added 25 packages, and audited 211 packages in 3s

39 packages are looking for funding
  run `npm fund` for details

4 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for detail...
white prawnBOT
white prawnBOT
white prawnBOT
#

If you'd rather significantly rewrite your code to use a version of discord.js that hasn't been maintained for two years to avoid a bug that doesn't impact the current stable version and will be fixed whenever the next update is, then you're welcome to make that bad decision.

As I said, this will be fixed in the next release, but its unlikely that a release will be made just to fix this.

white prawnBOT
#

The overloads of ShardingManager#broadcastEval() were in the wrong order, causing usages of the form that passes context and shard being matched by the general version for no passed context causing àny` argument types of the passed function and wrong return type.

https://www.typescriptlang.org/play/?ts=5.5.4#code/JYWwDg9gTgLgBAbzgYQDbAKYDsYBo4DKAFgIZQAmwWA5gLIlYnUZT4wCeYGcAggO4lgMEgCNUGNp24ApAgHkAcgFEsAYwjlR4yV0ItgJdAC8M5OAF84AMygQQcAOSUAzuooA6AFbOHAbgBQ-uQYqqhk3KEkzs4o0FAhMMRklDT0jMxQ...

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

  1. User A installs Bot to their account.
  2. User A runs /command from Bot in their DMs with User B.
  3. Bot tries to send a message to User A's DMs (via user.send()).
  4. Fails! 50001 Missing Access error because Bot tried to send message to User B's DMs with User A instead of Bot's DMs with User A.

The bot sends reminders and has been struggling with seemingly spontaneous 50001 Missing Access errors for a while ...

#

To be clear, the library is putting a channel in cache as the bot's DMs that actually doesn't have the bot as a recipient. That causes user.send() to throw a 50001 Missing Access because the bot doesn't actually have access to the channel that is in cache as a DM channel that it is a recipient to. I very strongly disagree with the idea that it's not the library's job to check for this.

#

To be clear, the library is putting a channel in cache as the bot's DMs that actually doesn't have the bot as a recipient. That causes user.send() to throw a 50001 Missing Access because the bot doesn't actually have access to the channel that is in cache as a DM channel that it is a recipient to. I very strongly disagree with the idea that it's not the library's job to check for this.

Can I ask you to share a code sample or some more information about how you were able to determine ...

#

It's not a bug per-se, many thing in discord.js relies on cache. Ever since user-installable was introduced which made interactions possible in private channels, which was causing interaction to fail due to caching issues even with partials enabled. This was a deliberate choice. As I said, you need to do these checks yourself in your code or set the contexts appropriate

#
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Reviewing this I was wondering whether v14 would need XComponent classes for the new modal components. But looking through where they get used I found out that they wouldn't be used anywhere because LabelComponent isn't used anywhere either, so probably not needed.

Yeah it doesn't get used anywhere, i raised this internally here #1402934237358985246 message back when label component was introduced. The only reason i kept `Label...

white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

Our bot is unable to establish a voice connection. The connection begins normally but drops immediately after receiving OP 8 (Hello) from the voice gateway.

The networking state transitions from:

{"code":1,"ws":true,"udp":false}

to

{"code":6,"ws":false,"udp":false}

After this, the connection falls back to signalling and eventually times out with:

AbortError: The operation was aborted

The connection never rece...

#

I added additional debugging to try to capture the WebSocket close code, but the connection appears to drop immediately after OP 8 and before OP 2 is received.

The networking state transitions directly from:

{"code":1,"ws":true,"udp":false}

to

{"code":6,"ws":false,"udp":false}

without exposing a close code in the current debug output.

If there is a recommended way to surface the voice WebSocket close code from @discordjs/voice, I can capture and provide that as well.

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

public delete(): Promise<OmitPartialGroupDMChannel>;

This should contain a reason, similar to some of the following:

public pin(reason?: string): Promise<OmitPartialGroupDMChannel>;
public unpin(reason?: string): Promise<OmitPartialGroupDMChannel>;

The delete function should have a reason as the endpoint accepts a reason, as shown here: https://docs.discord.com/developers/resourc...

white prawnBOT
#

All you did was amend documentation, so this doesn't do anything runtime or compile time. Now the documentation is out of synchronisation with the typings–this pull request actually worsens the issue.

If you want to make an actual fix, read this review: https://github.com/discordjs/discord.js/pull/11363#pullrequestreview-3837324366

This should be present with a suitable default–not otional.

white prawnBOT
#

Summary

  • Fix Collector.resetTimer({ idle: newValue }) not properly resetting the idle timer
  • The old code only reset the idle timeout when this._idletimeout already existed, and kept the clear and set coupled inside the same conditional
  • Now the existing idle timeout is always cleared first, then a new one is created if an idle value is provided (either via the argument or from the original options)

Test plan

  • [ ] Call resetTimer({ idle: 5000 }) on a collector that was create...
white prawnBOT
#

I've updated the fix based on your feedback. Instead of just making the type optional, I've now ensured that FileUploadModalData.attachments is ALWAYS initialized as a Collection, even when empty.

Changes Made

Modified ModalSubmitInteraction.js to:

  • Check if component type is FileUpload (type 19)
  • ALWAYS create a Collection for attachments when processing a FileUpload component
  • This ensures attachments is never undefined, matching the runtime behavior

Code Change

\\javascript
//...

white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

  1. Create a discord bot and join a server with it.
  2. Start the code sample below with a .env like this
USER_ID=
GUILD_ID=
DISCORD_TOKEN=
  1. Watch how it always return "online" as the presence.

Code sample

require('dotenv').config();
const { Client, GatewayIntentBits } = require('discord.js');

const token = process.env.DISCORD_TOKEN;
const userId = process.env.USER_ID;
const guildId = pr...
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

The latest release has a high severity fix from unicidi. Can this be fixed?

----- npm audit ------

npm audit report

undici <=6.23.0
Severity: high
Undici has an unbounded decompression chain in HTTP responses on Node.js Fetch API via Content-Encoding leads to resource exhaustion - https://github.com/advisories/GHSA-g9mf-h72j-4rw9
Undici: Malicious WebSocket 64-bit length overflows parser and crashes the client...

#

We do not provide ETAs for releases. Additionally, considering undici's track record recently, waiting for updates isn't gonna be a reliable solution if your environment demands no such "vulnerabilities" are present. If need be, all the major package managers allow you to override versions, e.g. for yarn - you should be able to do this for undici no problem so long as it's not a semver major bump.

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

There's an issue with the overload types for GuildMessageManager.fetch, the return type becomes Message (or Message in dev) when using FetchMessagesOptions.

Code sample

(message.channel as Exclude).messages
      .fetch({ amount: 100, cache: false })
      .then((messages) => {
        messages.filter()
      })

Versions

  • discord.js 14.25.1
  • node 24.14.1
  • ts 5.9.2
  • macOS Ta...
white prawnBOT
#

Cannot reproduce:

<img width="683" height="298" alt="Image" src="https://github.com/user-attachments/assets/dad6186e-8a8e-4d7b-a658-7a2ce4314a37" />

One thing I will call out is that amount should have been highlighted in your IDE stating that does not exist, but it didn't. This leads me to believe you are either using a corrupt installation of discord.js or some custom package.

#
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "./dist",
    "declaration": true,
    "declarationDir": "./dist/types",
    "baseUrl": "./src",
    "paths": {
      "src/*": ["./*"]
    },
    "moduleResolution": "node",
    "allowImportingTsExtensions": true,
    "preserveSymlinks": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}

base con...

#

I believe it is a Discord source issue because upon modifying the source by switching the order of overloads, the typing issue is resolved.

+  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
  public fetch(options: MessageResolvable | FetchMessageOptions): Promise<Message<InGuild>>;
-  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
#

I still cannot reproduce the issue with Bun. Here's a CI check for a neutral environment for you to see: https://github.com/Jiralite/11469/actions/runs/23683195081

Side question, why does CategoryChannel not get excluded when message.channel.isTextBased()?

Because of the way your project is handled to perceive types. It's misconfigured somewhere, so you're going to have a lot more questions until you find the issue.

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

MessagePayload.resolveBody() crashes with TypeError: Cannot read properties of undefined (reading 'push') when options.attachments is provided without options.files, because files?.map() returns undefined and .push() is then called on it.

This affects any message.edit({ attachments: [...] }) call that keeps existing attachments without uploading new files.

Fix: default the files?.map() result to [] with ?? [].

white prawnBOT
white prawnBOT
#

Several getters access guild.members.me or guild.members.resolve() without guarding against null, causing TypeError when the bot's own member is not cached (e.g. without GuildMembers intent).

Add GuildUncachedMe checks consistent with the existing pattern in GuildMember.manageable, GuildEmoji.deletable, and GuildInvite.deletable.

Affected getters:

white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

Steps to reproduce with below code sample:

  1. Create a file where the checkboxgroupbuilder & labelbuilder will be in. Create a modal with it and set it up with your needs.
  2. Send a button or select menu into a channel.
  3. You will see a pop up with the checkbox and you will see that the check boxes are disabled.
  4. There isn't any error logs.

Code sample

const check = new CheckboxGroupBuilder()
...
#

After fixing your invalid syntax and filling in the missing pieces of your steps to reproduce:

import { ButtonStyle, CheckboxGroupBuilder, Client, ComponentType, Events, GatewayIntentBits, LabelBuilder, ModalBuilder, TextChannel } from 'discord.js';

const client = new Client({ intents: GatewayIntentBits.Guilds });

client.on(Events.InteractionCreate, async (interaction) => {
    if (!interaction.isButton()) return;

    const check = new CheckboxGroupBuilder()
        .setCust...
white prawnBOT
#

Fixes GuildChannels from another shard being cached as DMChannel on shard 0 when sending ephemeral interaaction replies with Channel partial enabled.

What happened before this fix:

  • Interaction with an ephemeral reply is sent in a guild channel on shard != 0
  • messageCreate emits on shard 0 because of the ephemeral message
  • the Channel partial causes the guild channel to be cached as DMChannel because data.guild_id is null in the messageCreate and recipients gets added by the getChannel() ...
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

In latest djs version 14.26.2 dms dont trigger the messagecreate event anymore. I downgraded to older versions and they worked again. I have no idea whats causing this so cant go in detail but ive seen others report on it too.

Code sample


Versions

  • discord js 14.26.2
  • node version 23

Issue priority

High (immediate attention needed)

Which partials do you have configured?

C...

white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

See below code sample. All the versions of discord.js I've tested before 14.18 are broken when trying to install in 2026, which is an issue for updating legacy versions step-by-step to the latest release. The issues are significantly magnified before 14.18.

The source of this is probably the use of caret ranges - multiple dependenc...

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Backports #10462

This is fully just a cherry pick, so I figured it was fine to ignore, but just a heads up that there were some linting errors on some of the docs comments for waveform

.../discord.js/packages/discord.js/src/structures/Attachment.js
  12:1  error  This line has a length of 127. Maximum allowed is 120  max-len

.../discord.js/packages/discord.js/src/structures/AttachmentBuilder.js
  172:1  error  This line has a length of 126. Maximum allowed is 120  max-len
white prawnBOT
white prawnBOT
white prawnBOT
#

Which application or package is this feature request for?

discord.js

Feature

EmbedBuilder#setColor accepts ColorResolvable values (e.g. hex strings like "#00af89"), while ContainerBuilder#setAccentColor only accepts number | RGBTuple as documented.

Although this difference is intentional, both methods represent the same concept (a color value), and the inconsistency can be surprising when working across builders.

Example:

new EmbedBuilder().setColor("#00af89"); // ...
white prawnBOT
#

While technically fixing the mentioned issue this is sadly reintroducing the issue that #11462 was fixing. Can you checkout #11495 if it fixes the issue for you?

updated the PR to take the same approach as your #11495, just pass channel_type from the gateway event into getChannel so the existing type check works as intended. The diff is now a single line in MessageCreate.js, nothing else touched. Should be equivalent to what you have in #11495.

white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

I'm new to Discord bots and I think I've discovered a bug that prevents the bot from properly receiving DMs (direct messages) sent from a user to the bot. I rolled back to version 14.23.1 and it works fine, but it's broken on v14.23.2 and v14.23.3. However, it's working in the latest dev build which I tested for this GitHub issue ([email protected]).

I've distilled this down to minimal code...

white prawnBOT
white prawnBOT
#

Summary

  • Adds Message#threadable, mirroring the existing deletable / editable / crosspostable / pinnable getters. It returns whether the client user can start a thread from the message (parent channel type supports threads, no pre-existing thread, channel viewable, CreatePublicThreads permission).
  • Adds a matching BaseGuildTextChannel#threadable getter so TextChannel and AnnouncementChannel expose the channel-level check (viewable + CreatePublicThreads).
  • Updates th...
white prawnBOT
white prawnBOT
#

Good point, dropped the channel-level getter in 57ede0621. TextChannel can host both public and private threads (two separate permissions), so the boolean was ambiguous. Message#threadable stays because startThread on a message always creates a public thread, which makes the single CreatePublicThreads check unambiguous there. The PR body + description are also updated in scope accordingly.

white prawnBOT
#

You don't need a string to use hex. Remove the quotes or double quotes and then replace the hashtag with 0x.

  • setAccentColor("#00af89");
  • setAccentColor(0x00af89);
    The same goes for EmbedBuilder.setColor().

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#hexadecimal_numbers for more details.

You're right, 0x00af89 works.

My point was more about consistency with EmbedBuilder#setColor, which already accepts ColorResolvable, and a...

white prawnBOT
#

Closes #11286.

Root cause

`Collector#resetTimer` rebuilt `_timeout` / `_idletimeout` from its arguments but never wrote the new values back onto `this.options`. Any later code path that reads `this.options.idle` or `this.options.time` (the one in `handleCollect` resetting the idle timer after each collect is the loud one) kept using the old values, so the reset only held until the next collect came in.

It also returned early when the collector was started without a `time...

white prawnBOT
white prawnBOT
white prawnBOT
#

Confirming this bug independently on discord.js 14.26.3 (node 24 on macOS, bot connected via Gateway Intents: Guilds, GuildMessages, MessageContent, DirectMessages, GuildMessageReactions + Partials: Channel, Message).

Behaviour: Exact match — DM MESSAGE_CREATE packets arrive at the gateway (verified via a raw listener), but messageCreate never fires because createChannel() in util/Channels.js receives the message-shaped payload and checks data.type === ChannelType.DM (1), w...

white prawnBOT
#

Please describe the changes this PR makes and why it should be merged:

Fixes #11486. Also closes #11497 (duplicate report).

The bug

On v14, uncached DM channels never receive a messageCreate event. The first DM sent to a freshly-started bot is silently dropped; subsequent DMs from the same user hit the same path because the cache is never populated.

Reproducible with the minimal code sample from #11486 / #11497 against [email protected].

Root cause

Introduced in #11479. Tha...

white prawnBOT
#

Is this AI? The reasoning is completely wrong. main doesn't "already have this" nor was a fix introduced to main by #11462 since that was a backport into v14 branch and didn't even touch the else branch this is about.

main branch didn't merge the PR that introduced this yet because while it fixes a bug (that this PR would reintroduce) it also adds another bug (the one this PR claims to fix).

#11495 is the real fix for the issue without reintroducing any previous bugs that got fi...

white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

Hey, I'm trying to create a /ban command. I want the users to be able to appeal this ban with a /appeal command that they can execute in the bot's DM, but actually, the bot appears offline when they're banned.

So firtsly, I tried with the /ping command. When the users are on the guild, they can use the command in the bot's DM because it appears online. Then, when they're banned, the bot appears offline, so the user...

white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

Starting in v14.26.2, the messageCreate event no longer fires for direct messages sent to a bot. The bot connects to the gateway, receives MESSAGE_CREATE packets, but the event handler is never invoked. No errors are emitted. Guild messages work normally; only DMs are affected.

I bisected across all v14.x patch releases by extracting each tarball and comparing source: 14.14.1 through 14.26.1 work correctly, 14....

white prawnBOT
#

Confirming this regression independently. Also reproduces on 14.26.3 (latest). I bisected by extracting tarballs and diffing source: 14.14.1 through 14.26.1 work correctly; 14.26.2 and 14.26.3 are broken. The change is the single } else { ... }} else if (data.type === ChannelType.DM || data.type === ChannelType.GroupDM) { ... } modification you identified.

Notably, the v15 main branch (visible in 15.0.0-dev.1777075897-40ce0791a) already reverted this logic to:

if ...
white prawnBOT
#
5XS

Which package is this bug report for?

discord.js

Issue description

I don't really know how it happens, but my discord.js bots are not receiving some events sometimes. I have only seen it for GuildMemberAdd and GuildMemberUpdate. For example audit log event works for me perfectly and replaces GuildMemberUpdate when it comes to the roles.
Steps to reproduce:

  1. Create an event handler for one event
  2. Wait some time/events (it's not instant)

Code sample

// guildme...
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Please describe the changes this PR makes and why it should be merged:

Collector#resetTimer previously created new timers using the values
passed in but never wrote them back to this.options. As a result:

  1. The next automatic idle reset inside handleCollect (Collector.js:153) read the stale this.options.idle and re-armed the timer with the original construction-time value, so resetTimer was effectively undone on the next collected element.
  2. If a collector was cons...
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

The messages will time out trying to send files in messages when undici gets imported. When I remove the line importing undici, it works again. I rely on undici to make all my requests because I find it works better in my use cases than fetch, which is why I'm listing this as medium priority; otherwise I would need to rewrite the code of multiple of my bots to use fetch instead, which is more than slightly annoying....

white prawnBOT
#

Fixes modal fields unconditionally throwing when required is false/undefined.

* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty

An example jsdoc on most of the getters where it explicitly mentions the throwing on "not found", this implies that it shouldn't throw unconditionally.

This brings it inline with the command interaction options:

https://github.com/discordjs/discord.js/blob/40ce0791a8ed348189d9aefe0669ce...

#

Wouldn't this be a breaking change? And the behaviour is correct. The docs says it'll will throw an error if the values don't exist, which implies the component should exist first.

Historically modal components have always thrown an error if it was not found.

Though I do think its behaviour should be aligned to match command options, but perhaps on main since I think it would be breaking on v14

#

Wouldn't this be a breaking change

Yeah probably on the .getField

The docs says it'll will throw an error if the values don't exist, which implies the component should exist first.

At very least in the getters it documents the "not found" part. I could in theory make a private .getField instead so the public api stays the same. In current state those getters have no reason to even be able to return null?

https://github.com/discordjs/discord.js/blob/0516dc7862c71ffd2b49bde4e067...

#

At very least in the getters it documents the "not found" part. I could in theory make a private .getField instead so the public api stays the same. In current state some of those getters have no reason to even be able to return null?

You are right, that method shouldn't need required field, because I believe discord always returns a string (just empty). It should be like other fields with value as prop

#

@imnaiyar If I make the default value for .getField required true (so current code works the same), would that be a fair compromise. Like I'd be willing to say that people like me saw the jsdoc and understood it as the same as slash command one. But as this didn't mention it at all, it indeed shouldn't be changed

Or are you saying none of them can be seen as a bug fix as its still going to change peoples behavior? Like I'd argue it would cause more issues if we remove the "useless" param a...

white prawnBOT
#

There's something inherently different about what "required" means for Modal fields and for chatinput commands though.

  • If a command has an option as required: false then that option might be completely missing from the command interaction, if not used. So the check needs to account for that.
  • If a Modal has a component in it, then that component will also appear in the ModalSubmitInteraction's fields data. The values might be empty, but the field will always be present.

What you are...

white prawnBOT
#

@Qjuh that is a reasonable answer. However it does feel a little confusing considering consistency of knowing slash commands and the jsdoc mentioned. If you believe it's correct though, then I'll be happy to at very least fix that in a diff pr!

But required does make sense to me being actually need to be present vs just not empty. Logically it does make sense the reasoning behind slash commands are easy to have optional, however when making stateless options you may have many options again...

white prawnBOT
#

Which application or package is this feature request for?

discord.js

Feature

Discord modals with file inputs do not allow pre-filling existing files when opening the modal. This makes it impossible to build proper “edit message” workflows where a message already contains attachments, because there is no way to display those existing files inside the modal for modification.

Ideal solution or implementation

When opening a modal that contains a file input component, it should be...

white prawnBOT
#

@almeidx what do you think of adding id || "0" to the rest package route declarations so that if you do
Routes.applicationCommand("", "") you will get /applications/0/commands/0 instead of /applications//commands/?
Or even /applications/<empty>/commands/<empty> so its more informative if you see it in the logs?

Because I think there is actually a lot more places that empty strings will break typing guarantees then I initially thought and I don't think adding something like this ...

white prawnBOT
#

Also, I just realized it would be very easy to accidentally pass unsanitized user input into the URL since IDs are represented as strings. For example, if you want to check whether a user exists, you might naturally write users.fetch(input). The fact that input is ultimately interpolated into the URL is essentially an implementation detail, so it’s easy for someone using the API not to realize they’re introducing unsanitized input into a URL path. So I am thinking the routes should also do ...

white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

The examples below reference to the data of a UserSelect menu for visualization but also apply to the data of RoleSelect, ChannelSelect and MentionableSelect (especially its individual map properties).

If SelectMenuModalData has values, [FileUploadModalData](https://discord.js.org/docs/packages/discord.js/14.26....

white prawnBOT
#

Summary

RoleManager#edit already supports clearing gradient colors by passing null for secondaryColor/tertiaryColor — the runtime short-circuits on falsy values and sends secondary_color: null / tertiary_color: null in the PATCH body, which Discord interprets as "clear this color". However, RoleColorsResolvable typed those fields as ColorResolvable | undefined, so consumers couldn't pass null without a type error.

The output type RoleColors already exposes these a...

white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
white prawnBOT
#

Which package is this bug report for?

discord.js

Issue description

During sharding reconnection, if the bot leaves the guild, the guild will remain in the cache when the session is resumed.
I discovered this bug back on February 27, 2026, but because I was using my library, I only fixed this but for myself.

Steps:

  1. Wait for the ClientReady event
  2. Turn off the Internet
  3. Remove the app from the guild
  4. Turn on the Internet
  5. Wait for the ClientReady event

Code sampl...

#

https://github.com/discordjs/discord.js/blob/3d6121589f9c0d91f7cf4976307e8be07053a277/packages/discord.js/src/client/websocket/handlers/READY.js#L18
Furthermore, expected guilds are not cleared before being added.
If the shard is suddenly interrupted while the client is in the WaitingForGuilds status, and then guilds that haven't yet arrived in the GuildCreate event leave, the client will be stuck in the WaitingForGuilds status, waiting for the guild the bot left.

white prawnBOT
white prawnBOT
white prawnBOT
#

Not a maintainer, but one thing worth separating here is that audit log events working does not prove the member gateway events are configured correctly. GuildMemberAdd / GuildMemberUpdate depend on the GuildMembers privileged intent being enabled both in code and in the Discord Developer Portal for the application.

A couple of checks that would make this easier to triage:

  • confirm the Server Members Intent is enabled in the Developer Portal, not only GatewayIntentBits.GuildMembers...
white prawnBOT
#

Not a maintainer, but there are two version details here that seem important for narrowing this down.

For [email protected], @discordjs/rest depends on [email protected], while the repro imports [email protected] directly. The file-upload path in @discordjs/rest builds a new FormData() with Blobs, then the undici request strategy passes bodies through when body instanceof FormData.

So the useful split to test is whether this is caused by the app importing any undici, or specifical...