Skip to content

Commit

Permalink
fix: Image
Browse files Browse the repository at this point in the history
  • Loading branch information
deanxv committed Jul 2, 2024
1 parent 9bb9647 commit 79a0f79
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions discord/processmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ func processMessageUpdateForOpenAIImage(m *discordgo.MessageUpdate) model.OpenAI
}
}

if len(m.Attachments) != 0 {
for _, attachment := range m.Attachments {
if attachment.URL != "" && !strings.Contains(m.Content, attachment.URL) {
// if m.Content != "" {
// m.Content += "\n"
// }
response.Data = append(response.Data, &model.OpenAIImagesGenerationDataResponse{
URL: attachment.URL,
RevisedPrompt: m.Content,
})
}
}
}

return model.OpenAIImagesGenerationResponse{
Created: time.Now().Unix(),
Data: response.Data,
Expand Down Expand Up @@ -204,6 +218,20 @@ func processMessageCreateForOpenAIImage(m *discordgo.MessageCreate) model.OpenAI
}
}

if len(m.Attachments) != 0 {
for _, attachment := range m.Attachments {
if attachment.URL != "" && !strings.Contains(m.Content, attachment.URL) {
// if m.Content != "" {
// m.Content += "\n"
// }
response.Data = append(response.Data, &model.OpenAIImagesGenerationDataResponse{
URL: attachment.URL,
RevisedPrompt: m.Content,
})
}
}
}

return model.OpenAIImagesGenerationResponse{
Created: time.Now().Unix(),
Data: response.Data,
Expand Down

0 comments on commit 79a0f79

Please sign in to comment.