GithubHelp home page GithubHelp logo

itschip / guildedgo Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 104 KB

Guilded.gg Go Api client

Home Page: https://pkg.go.dev/github.com/itschip/guildedgo

License: MIT License

Go 100.00%
guilded-api guilded guilded-bot golang api guildedgg

guildedgo's Introduction

guildedgo

A guilded.gg library in Go

Getting started

go get github.com/itschip/guildedgo

Examples

Listen to events

package main

import (
        "fmt"

        "github.com/itschip/guildedgo"
)

func main() {
        guildedClient := guildedgo.NewClient(&guildedgo.Config{
                Token:    "YOUR_TOKEN",
                ServerID: "YOUR_SERVER_ID",
        })

        // Listen to the ChatMessageCreated event
        guildedClient.On("ChatMessageCreated", func(client *guildedgo.Client, v any) {
                data, ok := v.(*guildedgo.ChatMessageCreated)

                if ok {
                        fmt.Println(data.Message.Content)

                        if data.Message.Content == "!ping" {
                                guildedClient.Channel.SendMessage(data.Message.ChannelID, &guildedgo.MessageObject{
                                        Content: "pong!",
                                })
                        }

                }
        })

        // Open socket
        guildedClient.Open()
}

Command builder

serverID := internal.GetEnv("SERVER_ID")
	token := internal.GetEnv("TOKEN")

	config := &guildedgo.Config{
		ServerID: serverID,
		Token:    token,
	}

	c := guildedgo.NewClient(config)

	commands := &guildedgo.CommandsBuilder{
		Commands: []Command{
			{
				CommandName: "!test",
				Action: func(client *Client, v *ChatMessageCreated) {
					client.Channel.SendMessage(v.Message.ChannelID, &MessageObject{
						Content: "Test",
					})

					fmt.Println("Test working")
				},
			},
			{
				CommandName: "!party",
				Action: func(client *Client, v *ChatMessageCreated) {
					client.Channel.SendMessage(v.Message.ChannelID, &MessageObject{
						Content: "Yeah!!! Let's party",
					})

					fmt.Println("Party working")
				},
			},
		},
	}

	c.CommandService.AddCommands(commands)

	c.Open()

guildedgo's People

Contributors

itschip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

tooti31

guildedgo's Issues

Any roadmap on when this may be ready?

I'm attempting to make a guilded RESTful API, similar to Lanyard, etc. for discord. Planning on writing it in go, but I do not find any proper guilded go libraries. This looks good, so when is a proper release date for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.