C
C#2y ago
Nelson

Discord bot command that sends local images

Hello! Does anyone know how to make a discord bot command that is able to send locally stored images. I've seen the method 'SendFileAsync' being used, but it seems like it is unavailable to me in my VS2022. Is it only available in a specific package or? Any help appreciated!
7 Replies
Jimmacle
Jimmacle2y ago
$details
MODiX
MODiX2y ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Jimmacle
Jimmacle2y ago
what discord library are you using?
mindhardt
mindhardt2y ago
If it is somewhat similar to disqord then you need to create an Attachment object from stream (in your case filestream) and filename, then add it to a message and send it
jcotton42
jcotton422y ago
the only correct answer to this question is "Remora" andyWhen
Nelson
NelsonOP2y ago
DSharpPlus, if I'm understanding you right
mindhardt
mindhardt2y ago
D#+ has DiscordMessageBuilder.WithFile(string, Stream) which does exactly what I said, you need to open a file stream, then create a message with file and then send it

Did you find this page helpful?