goscord

module
v0.0.0-...-4db50c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: MIT

README

Goscord

Goscord is a package for Golang that provides high level bindings to the Discord API.

Getting Started

Installing

# Init the module:
go mod init <url> 

# Install Goscord:
go get -u github.com/Goscord/goscord

Usage

Construct a new Discord client which can be used to access the variety of Discord API functions and to set callback functions for Discord events.

package main

import (
    "fmt"


    "github.com/Goscord/goscord/goscord"
    "github.com/Goscord/goscord/goscord/discord"
    "github.com/Goscord/goscord/goscord/gateway"
    "github.com/Goscord/goscord/goscord/gateway/event"
)

var client *gateway.Session

func main() {
    fmt.Println("Starting...")

    client := goscord.New(&gateway.Options{
        Token:   "token",
        Intents: gateway.IntentGuildMessages,
    })

	client.On(event.EventReady, func() {
		fmt.Println("Logged in as " + client.Me().Tag())
	})

	client.On(event.EventMessageCreate, func(msg *discord.Message) {
		if msg.Content == "ping" {
			client.Channel.SendMessage(msg.ChannelId, "Pong ! 🏓")
		}
	})


    client.Login()

    select {}
}

See documentation for more detailed information.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL