Skip to content

Commit

Permalink
Update midjourney application command URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
igolaizola committed Jan 3, 2024
1 parent 314ac91 commit 34f7db0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/ai/midjourney/midjourney.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"log"
"math/rand"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -479,23 +478,20 @@ func (c *Client) Start(ctx context.Context) error {
return fmt.Errorf("midjourney: couldn't find application id for user %s", botID)
}

u = fmt.Sprintf("channels/%s/application-commands/search?type=1&include_applications=true", c.channelID)
u = fmt.Sprintf("channels/%s/application-command-index", c.channelID)
resp, err = c.c.Do(ctx, "GET", u, nil)
if err != nil {
return fmt.Errorf("midjourney: couldn't get application command search: %w", err)
return fmt.Errorf("midjourney: couldn't get channel application commands: %w", err)
}
if err := json.Unmarshal(resp, &appSearch); err != nil {
return fmt.Errorf("midjourney: couldn't unmarshal application command search %s: %w", string(resp), err)
}
default:
// Search for command in a guild channel
typings := []string{"im", "ima", "imag", "imagi", "imagin"}
typing := typings[rand.Intn(len(typings))]

u := fmt.Sprintf("channels/%s/application-commands/search?type=1&query=%s&limit=7&include_applications=false", c.channelID, typing)
u := fmt.Sprintf("guilds/%s/application-command-index", c.guildID)
resp, err := c.c.Do(ctx, "GET", u, nil)
if err != nil {
return fmt.Errorf("midjourney: couldn't get application command search: %w", err)
return fmt.Errorf("midjourney: couldn't get guild application commands: %w", err)
}
if err := json.Unmarshal(resp, &appSearch); err != nil {
return fmt.Errorf("midjourney: couldn't unmarshal application command search %s: %w", string(resp), err)
Expand Down

0 comments on commit 34f7db0

Please sign in to comment.