Fixed S3 upload names

This commit is contained in:
2024-01-19 14:33:37 -07:00
parent 96e8318f06
commit f31739a59b
2 changed files with 20 additions and 4 deletions

11
main.go
View File

@ -10,6 +10,7 @@ import (
"net"
"os"
"os/signal"
"strconv"
"time"
"github.com/diamondburned/arikawa/v3/api"
@ -183,7 +184,13 @@ func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.In
return errorResponse(err)
}
imageFile, err := lib.ReplicateImageGeneration(options.Prompt)
// Get current epoch timestamp
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
// Concatenate clean username and timestamp to form filename
filename := data.Event.Sender().Username + "_" + timestamp + ".jpg"
imageFile, err := lib.ReplicateImageGeneration(options.Prompt, filename)
if err != nil {
lib.CancelCooldown(data.Event.User.ID.String(), "pic")
@ -191,7 +198,7 @@ func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.In
}
file := sendpart.File{
Name: "himbot_response.png",
Name: filename,
Reader: imageFile,
}