Skip to content

Commit

Permalink
Support attached images when issuing warnings to user
Browse files Browse the repository at this point in the history
The purpose is to allow moderators to add an attached image when issuing a warning to a user. Usecase would be a screenshot of the offense like DM advertisement

/warnings will show attached image as part of the warning "reason".
  • Loading branch information
Sasiko authored Dec 1, 2024
1 parent 7fa8aa7 commit 0a65ac5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions moderation/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,23 @@ var ModerationCommands = []*commands.YAGCommand{
if parsed.TraditionalTriggerData != nil {
msg = parsed.TraditionalTriggerData.Message
}
err = WarnUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, target, parsed.Args[1].Str(), parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true)
if err != nil {
return nil, err
}

return GenericCmdResp(MAWarned, target, 0, false, true), nil
},
// Check for attachments in the message
attachmentURLs := make([]string, 0)
for _, att := range msg.Attachments {
attachmentURLs = append(attachmentURLs, att.URL)
}
// Add attachment URLs to the reason
reason := parsed.Args[1].Str()
if len(attachmentURLs) > 0 {
reason = fmt.Sprintf("%s\n\nAttachments: %s", reason, strings.Join(attachmentURLs, ", "))
}

err = WarnUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, target, reason)
if err != nil {
return nil, err
}
return GenericCmdResp(MAWarned, target, 0, false, true), nil
},
},
{
CustomEnabled: true,
Expand Down

0 comments on commit 0a65ac5

Please sign in to comment.