Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itschip/guildedgo
Guilded.gg Go Api client
https://github.com/itschip/guildedgo
api golang guilded guilded-api guilded-bot guildedgg
Last synced: 15 days ago
JSON representation
Guilded.gg Go Api client
- Host: GitHub
- URL: https://github.com/itschip/guildedgo
- Owner: itschip
- License: mit
- Created: 2022-03-23T19:04:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-19T20:52:01.000Z (12 months ago)
- Last Synced: 2024-07-29T18:39:02.930Z (3 months ago)
- Topics: api, golang, guilded, guilded-api, guilded-bot, guildedgg
- Language: Go
- Homepage: https://pkg.go.dev/github.com/itschip/guildedgo
- Size: 102 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# guildedgo
A guilded.gg library in Go
## Getting started
```cmd
go get github.com/itschip/guildedgo
```## Examples
### Listen to events
```go
package mainimport (
"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
```go
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()
```