1
1
import { ArgumentStream , Lexer , Parser , type IUnorderedStrategy } from '@sapphire/lexure' ;
2
- import { AliasPiece , type AliasPieceJSON , type AliasStore } from '@sapphire/pieces' ;
2
+ import { AliasPiece , type AliasPieceJSON } from '@sapphire/pieces' ;
3
3
import { isNullish , type Awaitable , type NonNullObject } from '@sapphire/utilities' ;
4
4
import {
5
5
ChatInputCommandInteraction ,
@@ -11,13 +11,14 @@ import {
11
11
type Snowflake
12
12
} from 'discord.js' ;
13
13
import { Args } from '../parsers/Args' ;
14
- import { BucketScope } from '../types/Enums' ;
15
- import { acquire } from '../utils/application-commands/ApplicationCommandRegistries' ;
14
+ import { BucketScope , RegisterBehavior } from '../types/Enums' ;
15
+ import { acquire , getDefaultBehaviorWhenNotIdentical , handleBulkOverwrite } from '../utils/application-commands/ApplicationCommandRegistries' ;
16
16
import type { ApplicationCommandRegistry } from '../utils/application-commands/ApplicationCommandRegistry' ;
17
17
import { emitRegistryError } from '../utils/application-commands/emitRegistryError' ;
18
18
import { getNeededRegistryParameters } from '../utils/application-commands/getNeededParameters' ;
19
19
import { PreconditionContainerArray , type PreconditionEntryResolvable } from '../utils/preconditions/PreconditionContainerArray' ;
20
20
import { FlagUnorderedStrategy , type FlagStrategyOptions } from '../utils/strategies/FlagUnorderedStrategy' ;
21
+ import type { CommandStore } from './CommandStore' ;
21
22
22
23
export class Command < PreParseReturn = Args , O extends Command . Options = Command . Options > extends AliasPiece < O > {
23
24
/**
@@ -248,7 +249,7 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
248
249
249
250
public override async reload ( ) {
250
251
// Remove the aliases from the command store
251
- const store = this . store as AliasStore < this > ;
252
+ const store = this . store as CommandStore ;
252
253
const registry = this . applicationCommandRegistry ;
253
254
254
255
for ( const nameOrId of registry . chatInputCommands ) {
@@ -293,6 +294,12 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
293
294
}
294
295
}
295
296
297
+ // If the default behavior is set to bulk overwrite, handle it as such and return.
298
+ if ( getDefaultBehaviorWhenNotIdentical ( ) === RegisterBehavior . BulkOverwrite ) {
299
+ await handleBulkOverwrite ( store , this . container . client . application ! . commands ) ;
300
+ return ;
301
+ }
302
+
296
303
// Re-initialize the store and the API data (insert in the store handles the register method)
297
304
const { applicationCommands, globalCommands, guildCommands } = await getNeededRegistryParameters ( updatedRegistry . guildIdsToFetch ) ;
298
305
0 commit comments