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

164
Visualizações
Can I save information in message requests with Discord API?

I tried to send messages like this

client.api.channels(msg.channel.id).messages.post({
  data: {
    content: 'content',
    test: 'test'
  }
})

I was hoping that since it’s an API post request, it would save the test property.

const msgs = await client.api.channels(msg.channel.id).messages.get();
msg.channel.send(msgs[1].test) //error: cannot send an empty message

Changing .test to .content does send the content of the message the bot sent originally, but .test outputs undefined. Maybe I need to use node-fetch or https so it posts and gets directly?

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

0

You are sending the test property to the Discord API via a post request, but that doesn't mean Discord API will store that property to its database. It only cares about the data it knows and the rest gets dropped. All properties Discord stores about a message are listed here.

Discord API doesn't allow you to store arbitrary data inside of a message object.

Of course you could search for workarounds, like storing the data inside of an embed's color (if they are short enough) or an image, etc. I don't think that is a good solution to this problem, but depends on what you want to accomplish.

What you could do is to store the custom data yourself. Create some kind of middleware, that will send a message to the Discord API, retrieve the message object of the newly created message. And associate its id with your custom data and store it somewhere (e.g. your database, JSON file, etc.)

Later you can use a message's id to access your custom data.

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