Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 1.98 KB

README.md

File metadata and controls

68 lines (50 loc) · 1.98 KB

Discord

Go Report Card Godoc Releases LICENSE

A small go library to post messages to a Discord channel using Webhooks.

Setup

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.

Usage

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

Simple Text Message

discord.Say("Hello, world!")

Complex Message

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",
		},
	},
})

File Attachment

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)

Documentation

For more information see the package's documentation.

This package is not endorsed by or affiliated with Discord, inc.