Skip to content

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

License

Notifications You must be signed in to change notification settings

ecnepsnai/discord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages