@@ -18,17 +18,28 @@ class Discord extends NotificationProvider {
18
18
webhookUrl . searchParams . append ( "thread_id" , notification . threadId ) ;
19
19
}
20
20
21
+ // Check if the webhook has an avatar
22
+ let webhookHasAvatar = true ;
23
+ try {
24
+ const webhookInfo = await axios . get ( webhookUrl . toString ( ) ) ;
25
+ webhookHasAvatar = ! ! webhookInfo . data . avatar ;
26
+ } catch ( e ) {
27
+ // If we can't verify, we assume he has an avatar to avoid forcing the default avatar
28
+ webhookHasAvatar = true ;
29
+ }
30
+
21
31
// If heartbeatJSON is null, assume we're testing.
22
32
if ( heartbeatJSON == null ) {
23
33
let discordtestdata = {
24
34
username : discordDisplayName ,
25
35
content : msg ,
26
36
} ;
27
-
37
+ if ( ! webhookHasAvatar ) {
38
+ discordtestdata . avatar_url = "https://github.com/louislam/uptime-kuma/raw/master/public/icon.png" ;
39
+ }
28
40
if ( notification . discordChannelType === "createNewForumPost" ) {
29
41
discordtestdata . thread_name = notification . postName ;
30
42
}
31
-
32
43
await axios . post ( webhookUrl . toString ( ) , discordtestdata ) ;
33
44
return okMsg ;
34
45
}
@@ -61,6 +72,9 @@ class Discord extends NotificationProvider {
61
72
] ,
62
73
} ] ,
63
74
} ;
75
+ if ( ! webhookHasAvatar ) {
76
+ discorddowndata . avatar_url = "https://github.com/louislam/uptime-kuma/raw/master/public/icon.png" ;
77
+ }
64
78
if ( notification . discordChannelType === "createNewForumPost" ) {
65
79
discorddowndata . thread_name = notification . postName ;
66
80
}
@@ -98,6 +112,9 @@ class Discord extends NotificationProvider {
98
112
] ,
99
113
} ] ,
100
114
} ;
115
+ if ( ! webhookHasAvatar ) {
116
+ discordupdata . avatar_url = "https://github.com/louislam/uptime-kuma/raw/master/public/icon.png" ;
117
+ }
101
118
102
119
if ( notification . discordChannelType === "createNewForumPost" ) {
103
120
discordupdata . thread_name = notification . postName ;
0 commit comments