Revolt.go is a Go package for writing bots and self-bots for Revolt.
- Event listener.
- Easy to use.
- Support for self bots.
- Simple caching system.
- Create a new project and initiate the go.mod file.
go mod init example
- Install the package using
go get github.com/ben-forster/revolt
- Create your main bot file.
touch main.go
Click here for the library's API reference.
Official documentation will come in the near future.
Please note that you will need Go 1.21 to use this library.
This package is still under development and while you can create a working bot, the library is not finished. You can see a development roadmap here. Please create an issue if you would like to contribute.
package main
import (
"os"
"os/signal"
"syscall"
"github.com/ben-forster/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()
}
package main
import (
"os"
"os/signal"
"syscall"
"github.com/ben-forster/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()
}
This project is a mantained and re-worked version of 5elenay's library revoltgo.