Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
How to make `CommandInteraction.reply()` return a `Message` using the discord API

I have the following (typescript) code snippet that generates an embed in response to an interaction, and sends it:

const embed = await this.generateEmbed(...);
await interaction.reply({embeds: [embed]});
const sentMessage: Message = <Message<boolean>> await interaction.fetchReply();
await sentMessage.react('⬅');

However, this fails at runtime because TypeError: sentMessage.react is not a function.

This is somewhat explained in the discord.js docs:

Returns the raw message data if the webhook was instantiated as a WebhookClient or if the channel is uncached, otherwise a Message will be returned

However, this happens even if I cache everything:

const bot = new Client({
    makeCache: Options.cacheEverything(),
    ...
});

Also note that I'm not using a WebhookClient here.

Why is CommandInteraction.reply() returning a raw message here, and how can I make it return a full Message object, so that I can use the .react() method?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I've done quite a bit of testing and I've come to the conclusion that this is happening because you're not requesting the GUILDS intent. I'm assuming that without the GUILDS intent, the GuildChannel cannot be cached, nor the Message, so it returns the raw data from the API.

const { Client, Intents } = require('discord.js');

const bot = new Client({
    intents: [Intents.FLAGS.GUILDS],
    ...
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda