Skip to content

Commit

Permalink
Debug bot settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferlund committed Dec 15, 2023
1 parent e6727f2 commit f78d2c6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/discord-bot/src/utils/settingsUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Setting } from './api-schema';
import { apiGet } from './api';
import { logger } from './logger';

export const getDefaultSetting = (
key: string
Expand Down Expand Up @@ -49,6 +50,10 @@ export const getDefaultSetting = (
return 'Forward Failed :(';
case 'PRAISE_FAILED':
return 'Praise Failed :(';
case 'DISCORD_BOT_DIRECT_PRAISE_QUANTIFICATION_ENABLED':
return false;
case 'DISCORD_BOT_PRAISE_NOTIFICATIONS_ENABLED':
return true;
}
};

Expand All @@ -59,8 +64,15 @@ export const getSetting = async (
const setting = await apiGet<Setting[]>(`/settings?key=${key}`, {
headers: host ? { host: host } : {},
})
.then((res) => res.data[0].valueRealized)
.then((res) => {
return res.data[0].valueRealized
? res.data[0].valueRealized
: getDefaultSetting(key);
})
.catch(() => getDefaultSetting(key));

// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
logger.debug(`Setting ${key} is ${setting}`);

return setting;
};

0 comments on commit f78d2c6

Please sign in to comment.