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

390
Visualizações
How can I recieve attachments from discord.js interactions?

I'm trying to get an image attachment through a Discord slash command interaction, so I can send a manipulated version back to the user, but I just can't seem to be able to do it.

The interaction itself comes through alright, but the "image" option's object is just {name: 'image', type: undefined, value: '972518871573602374'}. I think it's strange that the type is undefined despite me clearly using the .addAttachmentOption() method.

Here's my command builder:

new SlashCommandBuilder()
  .setName("dither")
  .setDescription("Apply a dithering effect to an image")

  .addAttachmentOption((option)=> option
    .setRequired(true)
    .setName("image")
    .setDescription("The image to dither"))

  .addNumberOption((option)=> option
    .setRequired(false)
    .setName("intensity")
    .setDescription(`% of dithering to apply (${intensityDefault}% by default)`))
  .toJSON()

I thought the URL or something might be elsewhere in the interaction object but I couldn't find anything related to attachments. I also couldn't find anything about interaction attachments in the documentation so I thought I'd try here. Is it just an unimplemented feature? But why would there be a method for it then?

I'm also unsure of what the value property represents. I thought it could be the attachment ID, but even if I wanted to recreate the attachment URL myself I'd still need to know the filename.

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

0

According to https://discordjs.guide/interactions/slash-commands.html#parsing-options :

const attachment = interaction.options.getAttachment("image")

const name = attachment.name
const url = attachment.url
const proxyURL = attachment.proxyURL

Please note that, in the example above, I have used image because that was the name you attributed to the attachment -- .setName("image").

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