You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wanting to migrate from discordgo to arikawa, and one of the features it had was hooking on something like this: func(_ *discordgo.Session, m *discordgo.Event). Is there an equilavent in Arikawa? I tried looking but there didn't seem to be a way to hook on every event before it was decoded. This is how discordgo handled the struct by the way:
typeEventstruct {
Operationint`json:"op"`Sequenceint64`json:"s"`Typestring`json:"t"`RawData json.RawMessage`json:"d"`// Struct contains one of the other types in this file.Structinterface{} `json:"-"`
}
The text was updated successfully, but these errors were encountered:
There is no straightforward way to hook on every event before it's decoded, but there are some roundabout ways to achieve this:
You can probably swap out gateway.OpUnmarshalers with something that is a copy of the existing OpUnmarshalers with all functions wrapped, or
You can create a wrapper around ws.Conn which will give you control over the <-chan ws.Op channel.
It might be worth it to also route every single ws.Op value through the handler, but that will introduce a lot more work for a case that not a lot of people will care about:
--- a/utils/ws/ophandler/ophandler.go+++ b/utils/ws/ophandler/ophandler.go@@ -17,6 +17,7 @@ func Loop(src <-chan ws.Op, dst *handler.Handler) <-chan struct{} {
go func() {
for op := range src {
dst.Call(op.Data)
+ dst.Call(op)
}
close(done)
}()
I'm wanting to migrate from discordgo to arikawa, and one of the features it had was hooking on something like this:
func(_ *discordgo.Session, m *discordgo.Event)
. Is there an equilavent in Arikawa? I tried looking but there didn't seem to be a way to hook on every event before it was decoded. This is how discordgo handled the struct by the way:The text was updated successfully, but these errors were encountered: