Abstracted helpful functions and packages to aid in Discord client development.
ISC License
ningen provides abstractions that override Arikawa's existing state to provide behaviors more similar to the official client with more aggressive caching.
Using ningen is similar to using *state.State
, but you'd be handling around
*ningen.State
instead. Typically, it might look like this:
s, err := state.New(os.Getenv("TOKEN"))
if err != nil {
return errors.Wrap(err, "failed to create state")
}
n, err := ningen.FromState(s)
if err != nil {
return errors.Wrap(err, "failed to wrap state")
}
if err := n.Open(); err != nil {
return errors.Wrap(err, "failed to open connection to Discord")
}
return startApp(n)
Afterwards, *ningen.State
can be used as if it is *state.State
. The new
state will transparently behave more similarly to the official client.
In addition to wrapping, *ningen.State
also adds a few more stores that the
client can use:
n.NoteState
keeps track of known user notes, which can be seen on the clientn.ReadState
allows seeing which channels are not read as well as allowingn.MutedState
keeps track of which channels, categories and guilds are muted.n.EmojiState
keeps track of the user's emojis; it returns the appropriaten.MemberState
provides a way to lazily fetch the right-hand side member listn.RelationshipState
keeps track of which users are blocked or are friends.For detailed documentation of each state, see the reference documentation.
ningen also provides a built-in Discord Markdown parser using goldmark. For an example on how to implement a custom Markdown renderer that is compatible with ningen, see md/renderer.go.