Skip to content

Commit a51e05b

Browse files
committed
fix bug for discord
1 parent c297152 commit a51e05b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

discord/notify.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,23 @@ func (c *client) Send(message string) error {
5151
Content: c.opt.Text,
5252
}
5353

54-
inrec, _ := json.Marshal(whMsg)
54+
inrec, err := json.Marshal(whMsg)
55+
if err != nil {
56+
return err
57+
}
58+
5559
params := &req.Param{}
56-
json.Unmarshal(inrec, params)
60+
err = json.Unmarshal(inrec, params)
61+
if err != nil {
62+
return err
63+
}
5764

5865
ApiURL = ApiURL + c.opt.Channel + "/" + c.opt.Token
5966
resp, err := req.Post(ApiURL, *params)
6067
if err != nil {
6168
return err
6269
}
63-
r := &Resp{}
64-
err = resp.ToJSON(r)
6570

66-
if err != nil || err.Error() != "unexpected end of JSON input" {
67-
return err
68-
}
69-
return nil
71+
r := &Resp{}
72+
return resp.ToJSON(r)
7073
}

0 commit comments

Comments
 (0)