feat: error tolerant command registeration

This commit is contained in:
TrèsAbhi committed 2024-03-03 22:21:06 -06:00
1 parent cba93b3d55
commit 11a0c246dc
1 file changed
+8 -11
+8 -11
View File
@@ -112,19 +112,16 @@ export const COMMANDS_RAW: CommandRegistry[] = [
todayCommand, todayCommand,
]; ];
export const commands = Promise.all(COMMANDS_RAW).then((rawCommands) => export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
rawCommands.reduce<Record<string, CommandRegistryPromisable>>( return rawCommands.reduce<Record<string, CommandRegistryPromisable>>(
(accumulator, registry) => { (commands, registry) => {
if (isDev()) registry.command.setDefaultMemberPermissions(0); if (registry.status === 'rejected') return commands;
if (isDev()) registry.value.command.setDefaultMemberPermissions(0);
return { return { ...commands, [registry.value.command.name]: registry.value };
...accumulator,
[registry.command.name]: registry,
};
}, },
{}, {},
), );
); });
export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
[]; [];