Skip to content

Commit

Permalink
fix: 调整接口
Browse files Browse the repository at this point in the history
  • Loading branch information
bao-io committed Feb 24, 2024
1 parent bdfe91e commit 85e0feb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,18 @@ export class MidjourneyCommand {

getCommand(query: CommandName) {
if (!this.commandCaches[query]) {
const searchParams = new URLSearchParams({
type: '1',
query,
limit: '1',
include_applications: 'false',
})
return this.opts
.fetch(
`${this.opts.apiBaseUrl}/api/v9/channels/${this.opts.channel_id}/application-commands/search?${searchParams}`,
`${this.opts.apiBaseUrl}/api/v9/guilds/${this.opts.guild_id}/application-command-index`,
{
headers: { authorization: this.opts.token },
},
)
.then(res => res.json())
.then(({ application_commands }) => {
if (application_commands.length) {
this.commandCaches[query] = application_commands[0]
const detail = (application_commands as any[]).find(v => v.name === query)
if (detail) {
this.commandCaches[query] = detail
return this.commandCaches[query]
}
else {
Expand Down

0 comments on commit 85e0feb

Please sign in to comment.