fix: initialize voice encryption libs before first connection
- await sodium.ready + nacl preload (same as original jukebox) - Add generateDependencyReport() for debugging - Add type declarations for libsodium-wrappers and tweetnacl Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1d4a48cf74
commit
9ac1034e5e
2 changed files with 11 additions and 0 deletions
|
|
@ -9,8 +9,11 @@ import {
|
||||||
joinVoiceChannel, createAudioPlayer, createAudioResource,
|
joinVoiceChannel, createAudioPlayer, createAudioResource,
|
||||||
AudioPlayerStatus, NoSubscriberBehavior, getVoiceConnection,
|
AudioPlayerStatus, NoSubscriberBehavior, getVoiceConnection,
|
||||||
VoiceConnectionStatus, StreamType, entersState,
|
VoiceConnectionStatus, StreamType, entersState,
|
||||||
|
generateDependencyReport,
|
||||||
type VoiceConnection, type AudioResource,
|
type VoiceConnection, type AudioResource,
|
||||||
} from '@discordjs/voice';
|
} from '@discordjs/voice';
|
||||||
|
import sodium from 'libsodium-wrappers';
|
||||||
|
import nacl from 'tweetnacl';
|
||||||
import { ChannelType, Events, type VoiceState, type Message } from 'discord.js';
|
import { ChannelType, Events, type VoiceState, type Message } from 'discord.js';
|
||||||
import type { Plugin, PluginContext } from '../../core/plugin.js';
|
import type { Plugin, PluginContext } from '../../core/plugin.js';
|
||||||
import { sseBroadcast } from '../../core/sse.js';
|
import { sseBroadcast } from '../../core/sse.js';
|
||||||
|
|
@ -481,6 +484,12 @@ const soundboardPlugin: Plugin = {
|
||||||
fs.mkdirSync(SOUNDS_DIR, { recursive: true });
|
fs.mkdirSync(SOUNDS_DIR, { recursive: true });
|
||||||
fs.mkdirSync(NORM_CACHE_DIR, { recursive: true });
|
fs.mkdirSync(NORM_CACHE_DIR, { recursive: true });
|
||||||
persistedState = readPersistedState();
|
persistedState = readPersistedState();
|
||||||
|
|
||||||
|
// Voice encryption libs must be initialized before first voice connection
|
||||||
|
await sodium.ready;
|
||||||
|
void nacl.randomBytes(1);
|
||||||
|
console.log(generateDependencyReport());
|
||||||
|
|
||||||
console.log(`[Soundboard] ${listAllSounds().length} sounds, ${persistedState.totalPlays ?? 0} total plays`);
|
console.log(`[Soundboard] ${listAllSounds().length} sounds, ${persistedState.totalPlays ?? 0} total plays`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
2
server/src/types/modules.d.ts
vendored
Normal file
2
server/src/types/modules.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare module "libsodium-wrappers";
|
||||||
|
declare module "tweetnacl";
|
||||||
Loading…
Add table
Add a link
Reference in a new issue