12345678910111213141516171819202122232425262728293031323334 |
- package discordgo
- import (
- "bytes"
- "encoding/json"
- "fmt"
- )
- func printEvent(e *Event) {
- fmt.Println(fmt.Sprintf("Event. Type: %s, State: %d Operation: %d Direction: %d", e.Type, e.State, e.Operation, e.Direction))
- printJSON(e.RawData)
- }
- func printJSON(body []byte) {
- var prettyJSON bytes.Buffer
- error := json.Indent(&prettyJSON, body, "", "\t")
- if error != nil {
- fmt.Print("JSON parse error: ", error)
- }
- fmt.Println(string(prettyJSON.Bytes()))
- }
|