Skip to content

discord-text-hook is a package for sending text message to discord channel via discord webhook. This is very minimal service which can send text message, edit a sent message and delete a sent message.

Notifications You must be signed in to change notification settings

nahidhasan98/discord-text-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Webhook (minimal text only version)

discord-text-hook is a package for sending text message to discord channel via discord webhook. This is very minimal service which can send text message, edit a sent message and delete a sent message.

Installation

go get github.com/nahidhasan98/discord-text-hook

Usage

Here is a minimal example usage that will send, edit and delete a message to discord channel.

package main

import (
	"fmt"
	"time"

	discordtexthook "github.com/nahidhasan98/discord-text-hook"
)

func main() {
	webhookID := "yourWebhookID"
	webhookToken := "yourWebhookToken"

	// initializing new discord-text-hook service
	discord := discordtexthook.NewDiscordTextHookService(webhookID, webhookToken)

	// sending a new message
	response, err := discord.SendMessage("Hello one")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("Message sent. Message ID:", response.ID)

	// sleeping for 1 second
	time.Sleep(1 * time.Second)

	// editing a sent message
	response, err = discord.EditMessage("Hello two", response.ID)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("Message edited")

	// sleeping for 1 second
	time.Sleep(1 * time.Second)

	// deleting a sent message
	err = discord.DeleteMessage(response.ID)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("Message deleted")
}

About

discord-text-hook is a package for sending text message to discord channel via discord webhook. This is very minimal service which can send text message, edit a sent message and delete a sent message.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages