diff --git a/src/core/DisTubeHandler.ts b/src/core/DisTubeHandler.ts index a26023c..3dc3a65 100644 --- a/src/core/DisTubeHandler.ts +++ b/src/core/DisTubeHandler.ts @@ -122,7 +122,7 @@ export class DisTubeHandler extends DisTubeBase { headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " + - "Chrome/125.0.0.0 Safari/537.36", + "Chrome/129.0.0.0 Safari/537.3", }, }); diff --git a/src/core/DisTubeVoice.ts b/src/core/DisTubeVoice.ts index cf0bece..a07c52a 100644 --- a/src/core/DisTubeVoice.ts +++ b/src/core/DisTubeVoice.ts @@ -1,6 +1,6 @@ import { Constants } from "discord.js"; import { TypedEmitter } from "tiny-typed-emitter"; -import { DisTubeError, isSupportedVoiceChannel } from ".."; +import { checkEncryptionLibraries, DisTubeError, isSupportedVoiceChannel } from ".."; import { AudioPlayerStatus, VoiceConnectionDisconnectReason, @@ -114,6 +114,7 @@ export class DisTubeVoice extends TypedEmitter { return joinVoiceChannel({ channelId: channel.id, guildId: this.id, + // @ts-ignore adapterCreator: channel.guild.voiceAdapterCreator, group: channel.client.user?.id, }); @@ -161,6 +162,10 @@ export class DisTubeVoice extends TypedEmitter { * @param dtStream - DisTubeStream */ play(dtStream: DisTubeStream) { + if (!checkEncryptionLibraries()) { + dtStream.kill(); + throw new DisTubeError("ENCRYPTION_LIBRARIES_MISSING"); + } this.emittedError = false; dtStream.on("error", (error: NodeJS.ErrnoException) => { if (this.emittedError || error.code === "ERR_STREAM_PREMATURE_CLOSE") return; diff --git a/src/struct/DisTubeError.ts b/src/struct/DisTubeError.ts index 14f94f4..c2f9595 100644 --- a/src/struct/DisTubeError.ts +++ b/src/struct/DisTubeError.ts @@ -29,6 +29,8 @@ const ERROR_MESSAGES = { FFMPEG_EXITED: (code: number) => `ffmpeg exited with code ${code}`, FFMPEG_NOT_INSTALLED: (path: string) => `ffmpeg is not installed at '${path}' path`, + ENCRYPTION_LIBRARIES_MISSING: + "Cannot play audio as no valid encryption package is installed. Please install sodium-native, sodium, libsodium-wrappers, or tweetnacl.", NO_QUEUE: "There is no playing queue in this guild", QUEUE_EXIST: "This guild has a Queue already", diff --git a/src/util.ts b/src/util.ts index 1bed75d..c41aedb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -172,3 +172,13 @@ export function isNsfwChannel(channel?: GuildTextBasedChannel): boolean { export type Falsy = undefined | null | false | 0 | ""; export const isTruthy = (x: T | Falsy): x is T => Boolean(x); + +export const checkEncryptionLibraries = () => { + for (const lib of ["sodium-native", "sodium", "libsodium-wrappers", "tweetnacl"]) { + try { + require(lib); + return true; + } catch {} + } + return false; +};