fix: Add check on startup to see if ffmpeg is available

This commit is contained in:
Marius Begby committed 2023-12-12 16:10:31 +01:00
1 parent ee5451320e
commit 0b72e92693
1 file changed
+17
+17
View File
@@ -5,6 +5,7 @@ import 'dotenv/config';
import config from 'config';
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
import { randomUUID as uuidv4 } from 'node:crypto';
import { exec } from 'child_process';
import { Logger } from 'pino';
import loggerModule from './services/logger';
const shardingOptions: ShardingManagerOptions = config.get('shardingOptions');
@@ -54,4 +55,20 @@ manager.on('shardCreate', (shard: Shard) => {
});
});
exec('ffmpeg -version', (error) => {
if (error) {
const logger: Logger = loggerModule.child({
module: 'shardingManager',
name: 'shardingManager',
shardId: 'manager'
});
logger.error('FFmpeg is not installed or available on your system.');
logger.error('Install FFmpeg (https://ffmpeg.org/download.html) and try again.');
logger.error('If you are using Windows, make sure to add FFmpeg to your PATH.');
process.exit();
}
});
manager.spawn();