Debian Codegraph @

docpages/example_programs/the_basics/attachments.md

raw
1 \page attach-file Attaching a File to a Message
2
3 To attach a local file to an message, you can use dpp::utility::read_file. It's a helper function from D++ that allows you to read the file's content and sent it to discord.
4
5 An example of this:
6
7 \include{cpp} attachments1.cpp
8
9 Attachments via URL aren't possible. But there's a workaround for this! You can download the file and then attach it to the message.
10
11 Amazingly, D++ also has a function for this! You can use dpp::cluster::request to make HTTP requests, allowing you to go ahead and pull the content from a URL.
12
13 The following example program shows how to request a file and attach it to a message:
14
15 \include{cpp} attachments2.cpp
16
17 Here's another example of how to add a local image to an embed.
18
19 Upload the image in the same message as the embed and then reference it in the embed.
20
21 \include{cpp} attachments3.cpp