From 146e05450da5b733ee62e38d92c862529ee2259a Mon Sep 17 00:00:00 2001 From: mimu Date: Sun, 9 Oct 2022 11:10:38 +0200 Subject: [PATCH] add log --- commands/pinned.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commands/pinned.go b/commands/pinned.go index 028a21b..7ab69b5 100644 --- a/commands/pinned.go +++ b/commands/pinned.go @@ -14,6 +14,8 @@ var Pinned tempest.Command = tempest.Command{ Description: "will show a random pinned message", Options: []tempest.Option{}, SlashCommandHandler: func(itx tempest.CommandInteraction) { + log.Print("inside pinned command") + messages, err := getPinnedMessages(itx.Client.Rest, itx.ChannelId.String()) if err != nil { log.Printf("failed to get messages: %s", err.Error()) @@ -21,6 +23,8 @@ var Pinned tempest.Command = tempest.Command{ return } + log.Print("after get pinned messages") + messagesCount := len(messages) if messagesCount == 0 { @@ -30,12 +34,14 @@ var Pinned tempest.Command = tempest.Command{ idx := rand.Intn(messagesCount) + log.Printf("just before send message, %d, %d", idx, messagesCount) itx.Client.SendMessage(itx.ChannelId, messages[idx]) }, } func getPinnedMessages(rest tempest.Rest, channelID string) ([]tempest.Message, error) { route := fmt.Sprintf("/channels/%s/pins", channelID) + log.Printf("Route: %s", route) bytes, err := rest.Request("GET", route, nil) if err != nil { return nil, err @@ -43,6 +49,7 @@ func getPinnedMessages(rest tempest.Rest, channelID string) ([]tempest.Message, messages := []tempest.Message{} if err = json.Unmarshal(bytes, &messages); err != nil { + log.Printf("## error unmarshalling ## %s", err.Error()) return nil, err }