Skip to content

Library for using discord webhooks. Methods: Execute (returns Message), Modify (returns Webhook), Delete.

License

Notifications You must be signed in to change notification settings

sw33tLie/discordhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiscordHook

Go.Dev Go Report Card

This module is made for those, who wants to only use Discord webhooks. If you want more from Discord API, i would suggest you to use disgord.

Where to find webhook ID and token

You can find them in webhook URL https://discord.com/api/webhooks/WEBHOOK_ID_HERE/WEBHOOK_TOKEN_HERE

Examples

package main

import (
    "fmt"

    "github.com/nickname32/discordhook"
)

func main() {
    wa, err := discordhook.NewWebhookAPI(12345678900987654321, "TOKENtoken1234567890asdfghjkl", true, nil)
    if err != nil {
        panic(err)
    }

    wh, err := wa.Get(nil)
    if err != nil {
        panic(err)
    }

    fmt.Println(wh.Name)

    msg, err := wa.Execute(nil, &discordhook.WebhookExecuteParams{
        Content: "Example text",
        Embeds: []*discordhook.Embed{
            {
                Title:       "Hi there",
                Description: "This is description",
            },
        },
    }, nil, "")
    if err != nil {
        panic(err)
    }

    fmt.Println(msg.ID)

    wh, err = wa.Modify(nil, &discordhook.WebhookModifyParams{
        Name: "This is a new default webhook name",
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(wh)

    err = wa.Delete(nil)
    if err != nil {
        panic(err)
    }
}

About

Library for using discord webhooks. Methods: Execute (returns Message), Modify (returns Webhook), Delete.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages