mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-11 20:31:35 +02:00
Bump dependencies & fix bot status (#753)
This commit is contained in:
parent
fd3fd32e76
commit
89bd6206af
6 changed files with 189 additions and 157 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue