Message.reply() with fetchReply: true resolves to undefined in discord.js v14
0 reputation · 02 Jun 2020, 18:41 UTC
0 reputation · 02 Jun 2020, 18:41 UTC
When calling Message#reply() with the fetchReply: true option in discord.js v14, the returned promise is documented to resolve to the sent Message instance. In practice, the promise sometimes resolves to undefined instead, preventing callers from accessing the reply's ID, timestamp, or other properties.
The discrepancy appears across multiple Node.js versions (18 and 20) and may be influenced by recent Discord API changes. The library's issue tracker contains open reports describing the same symptom, but no stable release has addressed it. Because the behavior is not consistently reproducible in every environment, it is unclear whether the root cause lies in the library's response handling, a gateway intent configuration, or a Discord-side change.
fetchReply: true reliably return a Message versus undefined in the current stable release?35275 reputation · 03 Jun 2020, 04:27 UTC
View Channel and Read Message History permissions in the target channel, the necessary intents (Guilds, GuildMessages, and optionally MessageContent) are enabled, the reply is sent to a normal text channel or thread the bot can read, and the library is on the latest v14 patch release.channel.send({content, reply:{messageReference:msg.id}}).const sent = await channel.send(...); const fetched = await channel.messages.fetch(sent.id);.interaction.fetchReply() which has a dedicated code path that always returns the Message.The fetchReply:true option tells Discord.js to perform an extra REST call to retrieve the message that was just sent. If the bot cannot read the channel (missing permissions or intents) or the message cannot be fetched for any reason, the library falls back to resolving undefined instead of throwing. This behaviour is intentional in the current code base but is a known source of intermittent failures.
npm ls discord.js should show v14.x.x where x is the most recent patch (e.g., 14.13.0).Guilds and GuildMessages are enabled. If you need message content, enable MessageContent too.View Channel and Read Message History in the target channel. If the channel is a thread, the bot also needs Manage Threads and Read Message History on the parent channel.const sent = await channel.send({content, reply:{messageReference:msg.id}});
const fetched = await channel.messages.fetch(sent.id);
// fetched is now a Message instanceawait interaction.reply({content, fetchReply:true});
const reply = await interaction.fetchReply();One detail that can change the recommendation is whether the bot is sending the reply in a thread or a DM. If so, the permission model differs and the fetch step may be skipped. Please confirm the channel type you are targeting.
In short, fetchReply:true resolves to undefined most often because the bot cannot read the message it just sent. Ensuring the bot has the right permissions, intents, and that you’re on the latest v14 patch, and then using a manual fetch after a normal channel.send guarantees you a Message instance. Until the Discord.js team releases a patch that standardises the behaviour, this is the safest path.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.