Something went wrong. Try again.
/x/perimental project monorepo
Something went wrong. Try again.
README.md
revolt.go #
Revolt.go is a Go package for writing bots and self-bots in Revolt easily. This project is a mantained and re-worked version ben-forster's fork of 5elenay's library revoltgo.
Features #
- Multiple event listen
- Easy to use
- Supports self bots
- Simple cache system
API Reference #
Click here for api reference.
Notice #
Please note that you will need the Go 1.20 to use revolt.
This package is still under development and while you can create a working bot, the library is not finished. Create an issue if you would like to contribute.
Ping Pong Example (Bot) #
package main
import (
"os"
"os/signal"
"syscall"
"within.website/x/web/revolt"
)
func main() {
// Init a new client.
client := revolt.Client{
Token: "bot token",
}
// Listen a on message event.
client.OnMessage(func(m *revolt.Message) {
if m.Content == "!ping" {
sendMsg := &revolt.SendMessage{}
sendMsg.SetContent("🏓 Pong!")
m.Reply(true, sendMsg)
}
})
// Start the client.
client.Start()
// Wait for close.
sc := make(chan os.Signal, 1)
signal.Notify(
sc,
syscall.SIGINT,
syscall.SIGTERM,
os.Interrupt,
)
<-sc
// Destroy client.
client.Destroy()
}
Ping Pong Example (Self-Bot) #
package main
import (
"os"
"os/signal"
"syscall"
"within.website/x/web/revolt"
)
func main() {
// Init a new client.
client := revolt.Client{
SelfBot: &revolt.SelfBot{
Id: "session id",
SessionToken: "session token",
UserId: "user id",
},
}
// Listen a on message event.
client.OnMessage(func(m *revolt.Message) {
if m.Content == "!ping" {
sendMsg := &revolt.SendMessage{}
sendMsg.SetContent("🏓 Pong!")
m.Reply(true, sendMsg)
}
})
// Start the client.
client.Start()
// Wait for close.
sc := make(chan os.Signal, 1)
signal.Notify(
sc,
syscall.SIGINT,
syscall.SIGTERM,
os.Interrupt,
)
<-sc
// Destroy client.
client.Destroy()
}