From 8aa27946350f535a1a4d00998afdfb03690bf071 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 8 Dec 2023 17:19:28 +0000 Subject: [PATCH] Add feature flag to sync commands --- src/commands/gdrivesync.ts | 8 +++++++- src/commands/resync.ts | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/commands/gdrivesync.ts b/src/commands/gdrivesync.ts index 97009a2..fa1ac00 100644 --- a/src/commands/gdrivesync.ts +++ b/src/commands/gdrivesync.ts @@ -4,6 +4,7 @@ import { ExecException, exec } from "child_process"; import CardSetupFunction from "../Functions/CardSetupFunction"; import { CoreClient } from "../client/client"; import Config from "../database/entities/app/Config"; +import CardMetadataFunction from "../Functions/CardMetadataFunction"; export default class Gdrivesync extends Command { constructor() { @@ -34,7 +35,12 @@ export default class Gdrivesync extends Command { await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`); await Config.SetValue('safemode', 'true'); } else { - await CardSetupFunction.Execute(); + if (!(process.env.FEATURE_METADATA && process.env.FEATURE_METADATA == 'true')) { + await CardMetadataFunction.Execute(); + } else { + await CardSetupFunction.Execute(); + } + await interaction.editReply('Synced successfully.'); CoreClient.AllowDrops = true; diff --git a/src/commands/resync.ts b/src/commands/resync.ts index a3ea823..2ea3648 100644 --- a/src/commands/resync.ts +++ b/src/commands/resync.ts @@ -2,6 +2,7 @@ import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder import { Command } from "../type/command"; import CardSetupFunction from "../Functions/CardSetupFunction"; import Config from "../database/entities/app/Config"; +import CardMetadataFunction from "../Functions/CardMetadataFunction"; export default class Resync extends Command { constructor() { @@ -23,7 +24,15 @@ export default class Resync extends Command { return; } - if (await CardSetupFunction.Execute()) { + let result: boolean; + + if (!(process.env.FEATURE_METADATA && process.env.FEATURE_METADATA == 'true')) { + result = await CardMetadataFunction.Execute(); + } else { + result = await CardSetupFunction.Execute(); + } + + if (result) { if (await Config.GetValue('safemode') == "true") { await Config.SetValue('safemode', 'false'); await interaction.reply("Resynced database and disabled safe mode.");