Skip to content

Commit

Permalink
fix(core): default value fallback location
Browse files Browse the repository at this point in the history
some command that goes interaction/command (e.g., Discord) won't pass the function contains that logic.
  • Loading branch information
yhx-12243 committed Jun 4, 2024
1 parent d985a51 commit ad07387
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions packages/core/src/command/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,6 @@ export namespace Argv {
}
}

// assign default values
for (const { name, fallback } of Object.values(this._options)) {
if (fallback !== undefined && !(name in options)) {
options[name] = fallback
}
}

delete argv.tokens
return { ...argv, options, args, error: argv.error || '', command: this as any }
}
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ export class Session<U extends User.Field = never, G extends Channel.Field = nev
const { command } = argv
if (!command.ctx.filter(this)) return ''

// assign default values
for (const { name, fallback } of Object.values(command._options)) {
if (fallback !== undefined && !(name in argv.options)) {
argv.options[name] = fallback
}
}

if (this.app.database) {
if (!this.isDirect) {
await this.observeChannel(this.collect('channel', argv, new Set(['permissions', 'locales'])))
Expand Down

0 comments on commit ad07387

Please sign in to comment.