Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions handlers/crash_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func AddCrashLog(c *gin.Context) *APIError {
}

body := struct {
Runtime string `form:"runtime" json:"runtime" binding:"required"`
Network string `form:"network" json:"network" binding:"required"`
Runtime string `form:"runtime" json:"runtime" binding:"required"`
Network string `form:"network" json:"network" binding:"required"`
Version *string `form:"version" json:"version"`
}{}

if err := c.ShouldBind(&body); err != nil {
Expand All @@ -39,7 +40,7 @@ func AddCrashLog(c *gin.Context) *APIError {
return APIErrorServerError("Error inserting crash log", err)
}

if err := webhooks.SendCrashLogWebhook(user, crashLog); err != nil {
if err := webhooks.SendCrashLogWebhook(user, crashLog, body.Version); err != nil {
logrus.Error("Error sending crash log webhook: ", err)
}

Expand Down
13 changes: 9 additions & 4 deletions webhooks/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,21 +441,26 @@ func SendClanRankedWebhook(mapQua *db.MapQua) error {
return nil
}

func SendCrashLogWebhook(user *db.User, log *db.CrashLog) error {
func SendCrashLogWebhook(user *db.User, log *db.CrashLog, version *string) error {
if crashLog == nil {
return nil
}

embed := discord.NewEmbedBuilder().
embedBuilder := discord.NewEmbedBuilder().
SetAuthor(user.Username, fmt.Sprintf("https://quavergame.com/user/%v", user.Id), *user.AvatarUrl).
SetTitle("❌ Crash Log Submitted").
SetDescription("A new crash log has been submitted.").
AddField("Actions", fmt.Sprintf("[View Log](https://a.quavergame.com/logs/crash/%v)", log.Id), false).
SetThumbnail(QuaverLogo).
SetFooter("Quaver", QuaverLogo).
SetTimestamp(time.Now()).
SetColor(0xFF0000).
Build()
SetColor(0xFF0000)

if version != nil {
embedBuilder.AddField("Game Version", *version, true)
}

embed := embedBuilder.Build()

msg := discord.WebhookMessageCreate{
Embeds: []discord.Embed{embed},
Expand Down
Loading