Skip to content

Commit 5391a8a

Browse files
committed
chore: improvements
1 parent 8960ed0 commit 5391a8a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ const ApplicationCommandRegistries = {
2929
acquire,
3030
setDefaultBehaviorWhenNotIdentical,
3131
setDefaultGuildIds,
32-
setBulkRegisterCommandRetries: setBulkOverwriteRetries,
32+
setBulkOverwriteRetries,
3333
getDefaultGuildIds,
3434
getDefaultBehaviorWhenNotIdentical,
35-
getBulkRegisterCommandRetries: getBulkOverwriteRetries,
35+
getBulkOverwriteRetries,
3636
get registries(): ReadonlyMap<string, ApplicationCommandRegistry> {
3737
return registries;
3838
}

src/lib/utils/application-commands/ApplicationCommandRegistries.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ export function getDefaultGuildIds() {
6666

6767
/**
6868
* Sets the amount of retries for when registering commands, only applies when {@link defaultBehaviorWhenNotIdentical}
69-
* is set to {@link RegisterBehavior.BulkOverwrite}. This is used if registering the commands fails.
69+
* is set to {@link RegisterBehavior.BulkOverwrite}. This is used if registering the commands times out.
7070
* The default value is `1`, which means no retries are performed.
7171
* @param newAmountOfRetries The new amount of retries to set. Set this to `null` to reset it to the default
7272
*/
7373
export function setBulkOverwriteRetries(newAmountOfRetries: number | null) {
74-
bulkOVerwriteRetries = newAmountOfRetries ?? 1;
74+
newAmountOfRetries ??= 1;
75+
76+
if (newAmountOfRetries <= 0) throw new RangeError('The amount of retries must be greater than 0');
77+
78+
bulkOVerwriteRetries = newAmountOfRetries;
7579
}
7680

7781
export function getBulkOverwriteRetries() {
@@ -181,6 +185,8 @@ async function handleBulkOverwriteGlobalCommands(
181185

182186
bulkOverwriteInfo(`Successfully overwrote global application commands. The application now has ${result.size} global commands`);
183187
} catch (error) {
188+
if (error instanceof Error && error.name === 'AbortError') throw error;
189+
184190
emitBulkOverwriteError(error, null);
185191
}
186192
}
@@ -234,6 +240,8 @@ async function handleBulkOverwriteGuildCommands(
234240
`Successfully overwrote guild application commands for guild ${guildId}. The application now has ${result.size} guild commands for guild ${guildId}`
235241
);
236242
} catch (error) {
243+
if (error instanceof Error && error.name === 'AbortError') throw error;
244+
237245
emitBulkOverwriteError(error, guildId);
238246
}
239247
}

0 commit comments

Comments
 (0)