@@ -2,15 +2,16 @@ package webhooks
2
2
3
3
import (
4
4
"fmt"
5
+ "slices"
6
+ "strings"
7
+ "time"
8
+
5
9
"github.com/Quaver/api2/config"
6
10
"github.com/Quaver/api2/db"
7
11
"github.com/Quaver/api2/enums"
8
12
"github.com/disgoorg/disgo/discord"
9
13
"github.com/disgoorg/disgo/webhook"
10
14
"github.com/sirupsen/logrus"
11
- "slices"
12
- "strings"
13
- "time"
14
15
)
15
16
16
17
var (
20
21
teamAnnounce webhook.Client
21
22
clansFirstPlace webhook.Client
22
23
clansMapRanked webhook.Client
24
+ crashLog webhook.Client
23
25
)
24
26
25
27
const (
@@ -33,6 +35,7 @@ func InitializeWebhooks() {
33
35
teamAnnounce , _ = webhook .NewWithURL (config .Instance .TeamAnnounceWebhook )
34
36
clansFirstPlace , _ = webhook .NewWithURL (config .Instance .ClansFirstPlaceWebhook )
35
37
clansMapRanked , _ = webhook .NewWithURL (config .Instance .ClansMapRankedWebhook )
38
+ crashLog , _ = webhook .NewWithURL (config .Instance .CrashLogWebhook )
36
39
}
37
40
38
41
// SendQueueSubmitWebhook Sends a webhook displaying that the user submitted a mapset to the ranking queue
@@ -418,6 +421,36 @@ func SendClanRankedWebhook(mapQua *db.MapQua) error {
418
421
return nil
419
422
}
420
423
424
+ func SendCrashLogWebhook (user * db.User , log * db.CrashLog ) error {
425
+ if crashLog == nil {
426
+ return nil
427
+ }
428
+
429
+ embed := discord .NewEmbedBuilder ().
430
+ SetAuthor (user .Username , fmt .Sprintf ("https://quavergame.com/user/%v" , user .Id ), * user .AvatarUrl ).
431
+ SetTitle ("❌ Crash Log Submitted" ).
432
+ SetDescription ("A new crash log has been submitted." ).
433
+ AddField ("Actions" , fmt .Sprintf ("[View Log](https://a.quavergame.com/logs/crash/%v)" , log .Id ), false ).
434
+ SetThumbnail (QuaverLogo ).
435
+ SetFooter ("Quaver" , QuaverLogo ).
436
+ SetTimestamp (time .Now ()).
437
+ SetColor (0xFF0000 ).
438
+ Build ()
439
+
440
+ msg := discord.WebhookMessageCreate {
441
+ Embeds : []discord.Embed {embed },
442
+ }
443
+
444
+ _ , err := crashLog .CreateMessage (msg )
445
+
446
+ if err != nil {
447
+ logrus .Error ("Failed to send crash log event webhook: " , err )
448
+ return err
449
+ }
450
+
451
+ return nil
452
+ }
453
+
421
454
func getUserPingText (mapset * db.Mapset ) string {
422
455
content := ""
423
456
0 commit comments