aboutsummaryrefslogtreecommitdiff
path: root/src/services/config.ts
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2022-08-04 22:06:54 -0500
committerGitHub <[email protected]>2022-08-04 22:06:54 -0500
commit89bd6206af3e49ca119656c97c1fa19635120c08 (patch)
tree424d8a8e9870fc59b84483bb435a4ae1b9a8b3fc /src/services/config.ts
parentfd3fd32e7675aded4d334b6287d84e97568b4e4b (diff)
downloadmuse-89bd6206af3e49ca119656c97c1fa19635120c08.tar.xz
muse-89bd6206af3e49ca119656c97c1fa19635120c08.zip
Bump dependencies & fix bot status (#753)
Diffstat (limited to 'src/services/config.ts')
-rw-r--r--src/services/config.ts22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/services/config.ts b/src/services/config.ts
index ca4fc68..1cafd3c 100644
--- a/src/services/config.ts
+++ b/src/services/config.ts
@@ -4,6 +4,7 @@ import {injectable} from 'inversify';
import path from 'path';
import xbytes from 'xbytes';
import {ConditionalKeys} from 'type-fest';
+import {ActivityType, PresenceStatusData} from 'discord.js';
dotenv.config();
export const DATA_DIR = path.resolve(process.env.DATA_DIR ? process.env.DATA_DIR : './data');
@@ -18,11 +19,18 @@ const CONFIG_MAP = {
CACHE_DIR: path.join(DATA_DIR, 'cache'),
CACHE_LIMIT_IN_BYTES: xbytes.parseSize(process.env.CACHE_LIMIT ?? '2GB'),
BOT_STATUS: process.env.BOT_STATUS ?? 'online',
- BOT_ACTIVITY_TYPE: process.env.BOT_ACTIVITY_TYPE ?? 'Listening',
+ BOT_ACTIVITY_TYPE: process.env.BOT_ACTIVITY_TYPE ?? 'LISTENING',
BOT_ACTIVITY_URL: process.env.BOT_ACTIVITY_URL ?? '',
BOT_ACTIVITY: process.env.BOT_ACTIVITY ?? 'music',
} as const;
+const BOT_ACTIVITY_TYPE_MAP = {
+ PLAYING: ActivityType.Playing,
+ LISTENING: ActivityType.Listening,
+ WATCHING: ActivityType.Watching,
+ STREAMING: ActivityType.Streaming,
+} as const;
+
@injectable()
export default class Config {
readonly DISCORD_TOKEN!: string;
@@ -33,8 +41,8 @@ export default class Config {
readonly DATA_DIR!: string;
readonly CACHE_DIR!: string;
readonly CACHE_LIMIT_IN_BYTES!: number;
- readonly BOT_STATUS!: string;
- readonly BOT_ACTIVITY_TYPE!: string;
+ readonly BOT_STATUS!: PresenceStatusData;
+ readonly BOT_ACTIVITY_TYPE!: Exclude<ActivityType, ActivityType.Custom>;
readonly BOT_ACTIVITY_URL!: string;
readonly BOT_ACTIVITY!: string;
@@ -45,10 +53,16 @@ export default class Config {
process.exit(1);
}
+ if (key === 'BOT_ACTIVITY_TYPE') {
+ this[key] = BOT_ACTIVITY_TYPE_MAP[(value as string).toUpperCase() as keyof typeof BOT_ACTIVITY_TYPE_MAP];
+ continue;
+ }
+
if (typeof value === 'number') {
this[key as ConditionalKeys<typeof CONFIG_MAP, number>] = value;
} else if (typeof value === 'string') {
- this[key as ConditionalKeys<typeof CONFIG_MAP, string>] = value.trim();
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+ (this as any)[key] = value.trim();
} else if (typeof value === 'boolean') {
this[key as ConditionalKeys<typeof CONFIG_MAP, boolean>] = value;
} else {