mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-01-20 19:47:12 +00:00
API: Add File.AttachmentURI for convenience
This commit is contained in:
parent
3713c9d404
commit
f5dc90c2d4
|
@ -102,6 +102,8 @@ type SendMessageData struct {
|
|||
// Embed is embedded rich content.
|
||||
Embed *discord.Embed `json:"embed,omitempty"`
|
||||
|
||||
// Files is the list of file attachments to be uploaded. To reference a file
|
||||
// in an embed, use (sendpart.File).AttachmentURI().
|
||||
Files []sendpart.File `json:"-"`
|
||||
|
||||
// AllowedMentions are the allowed mentions for a message.
|
||||
|
|
|
@ -3,6 +3,7 @@ package sendpart
|
|||
import (
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/diamondburned/arikawa/v2/utils/httputil"
|
||||
|
@ -16,6 +17,16 @@ type File struct {
|
|||
Reader io.Reader
|
||||
}
|
||||
|
||||
// AttachmentURI returns the file encoded using the attachment URI required for
|
||||
// embedding an attachment image.
|
||||
func (f File) AttachmentURI() string {
|
||||
u := url.URL{
|
||||
Scheme: "attachment",
|
||||
Path: f.Name,
|
||||
}
|
||||
return u.String()
|
||||
}
|
||||
|
||||
// DataMultipartWriter is a MultipartWriter that also contains data that's
|
||||
// JSON-marshalable.
|
||||
type DataMultipartWriter interface {
|
||||
|
|
Loading…
Reference in a new issue