forked from ecnepsnai/discord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord_example_test.go
50 lines (46 loc) · 1015 Bytes
/
discord_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package discord_test
import (
"github.com/S5Projects/discord"
)
func ExampleSay() {
wh, err := discord.New("https://discord.com/api/webhooks/.../...")
if err != nil {
panic(err)
}
wh.Say("Hello, world!")
}
func ExamplePost() {
wh, err := discord.New("https://discord.com/api/webhooks/.../...")
if err != nil {
panic(err)
}
wh.Post(discord.PostOptions{
Content: "Hello, world!",
Embeds: []discord.Embed{
{
Color: 16777215,
Author: &discord.Author{
Name: "ecnepsnai",
URL: "https://github.com/ecnepsnai",
},
Title: "Amazing!",
Description: "This is a cool embed",
},
},
})
}
func ExampleUploadFile() {
wh, err := discord.New("https://discord.com/api/webhooks/.../...")
if err != nil {
panic(err)
}
// var f *io.Reader // Pretend we've opened a file
content := discord.PostOptions{
Content: "Hello, world!",
}
fileOptions := discord.FileOptions{
FileName: "my_hot_mixtape.mp3",
// Reader: f,
}
wh.UploadFile(content, fileOptions)
}