title: How to send an image with JDA
body: <p>im developing my Java bot for discord. And I want to send an image. I tried using <code>TextChannel.sendFile(File, Message)</code>, but it`s not that <strong>result that I want to get</strong>. I want this file to be displayed like a <strong>normal image</strong>.</p>
  
  <p>The imports:</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.concurrent.ThreadLocalRandom;
  
  import javax.xml.namespace.QName;
  import javax.xml.stream.FactoryConfigurationError;
  import javax.xml.stream.XMLEventReader;
  import javax.xml.stream.XMLInputFactory;
  import javax.xml.stream.XMLStreamException;
  import javax.xml.stream.events.Attribute;
  import javax.xml.stream.events.StartElement;
  import javax.xml.stream.events.XMLEvent;
  
  import org.apache.commons.io.FileUtils;
  
  import net.dv8tion.jda.core.MessageBuilder;
  import net.dv8tion.jda.core.entities.Message;
  import net.dv8tion.jda.core.entities.TextChannel;
  import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
  </code></pre>
  
  <p>And the other code:</p>
  
  <pre><code>        URL url = new URL(s.toString());
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  
          XMLEventReader reader = XMLInputFactory.newInstance().createXMLEventReader(conn.getInputStream());
          final List&lt;String&gt; files = new ArrayList&lt;&gt;();
  
          while (reader.hasNext()) {
              XMLEvent e = reader.nextEvent();
  
              if (e.isStartElement()) {
                  StartElement se = e.asStartElement();
  
                  if (se.getName().getLocalPart().equals("post")) {
                      Attribute purl = se.getAttributeByName(new QName("file_url"));
                      files.add(purl.getValue());
                  }
              }
          }
  
          int rid = ThreadLocalRandom.current().nextInt(files.size() - 1);
          String p = files.get(rid);
          files.clear();
  
          URL u = new URL(p);
  
          final String[] dots = p.split("\\.");
          final String format = dots[dots.length - 1];
  
          File f = new File("its not a porn." + format);
  
          FileUtils.copyURLToFile(url, f);
  
          Message m = new MessageBuilder().append("okay :)").build();
          c.sendFile(f, m).queue();
  }
  </code></pre>
  
  <p>I tried to find a solution somewhere but i haven found any info that could help.</p>