mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-10 12:11: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
|
@ -1,4 +1,4 @@
|
|||
import {Client, Collection, PresenceStatusData, User} from 'discord.js';
|
||||
import {Client, Collection, User} from 'discord.js';
|
||||
import {inject, injectable} from 'inversify';
|
||||
import ora from 'ora';
|
||||
import {TYPES} from './types.js';
|
||||
|
@ -12,7 +12,7 @@ import {isUserInVoice} from './utils/channels.js';
|
|||
import Config from './services/config.js';
|
||||
import {generateDependencyReport} from '@discordjs/voice';
|
||||
import {REST} from '@discordjs/rest';
|
||||
import {Routes, ActivityType} from 'discord-api-types/v10';
|
||||
import {Routes} from 'discord-api-types/v10';
|
||||
import registerCommandsOnGuild from './utils/register-commands-on-guild.js';
|
||||
|
||||
@injectable()
|
||||
|
@ -150,11 +150,11 @@ export default class {
|
|||
activities: [
|
||||
{
|
||||
name: this.config.BOT_ACTIVITY,
|
||||
type: this.config.BOT_ACTIVITY_TYPE as unknown as Exclude<ActivityType, ActivityType.Custom>,
|
||||
type: this.config.BOT_ACTIVITY_TYPE,
|
||||
url: this.config.BOT_ACTIVITY_URL === '' ? undefined : this.config.BOT_ACTIVITY_URL,
|
||||
},
|
||||
],
|
||||
status: this.config.BOT_STATUS as PresenceStatusData,
|
||||
status: this.config.BOT_STATUS,
|
||||
});
|
||||
|
||||
spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=36700160`);
|
||||
|
|
|
@ -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