A small go library to post messages to a Discord channel using Webhooks.
You must first configure a Webhook on a Discord server before you can use this package. Instructions can be found on Discord's support website.
You must first configure the Webhook URL that will be used
discord.WebhookURL = "https://discord.com/api/webhooks/.../..."
Then you can either send a simple text message or a more complex message
discord.Say("Hello, world!")
discord.Post(discord.PostOptions{
Content: "Hello, world!",
Embeds: []discord.Embed{
{
Author: discord.Author{
Name: "ecnepsnai",
URL: "https://github.com/ecnepsnai",
},
Title: "Amazing!",
Description: "This is a cool embed",
},
},
})
Restrictions with Discords Webhook API only supports 1 file upload at 8MiB or less.
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,
}
discord.UploadFile(content, fileOptions)
For more information see the package's documentation.
This package is not endorsed by or affiliated with Discord, inc.