diff --git a/packages/discord-player/src/clientadapter/ClientAdapterFactory.ts b/packages/discord-player/src/clientadapter/ClientAdapterFactory.ts index 95c2ce513..642fbe46a 100644 --- a/packages/discord-player/src/clientadapter/ClientAdapterFactory.ts +++ b/packages/discord-player/src/clientadapter/ClientAdapterFactory.ts @@ -56,17 +56,40 @@ export class ClientAdapterFactory { // throw new Error(`Failed to create client adapter: ${error}`); // } } +} - /** old code just in case */ - // private static getClientType(client: SupportedClient): ClientType { - // if (client instanceof DiscordJsClient) { - // return ClientType.DiscordJs; - // } +/** old code in case I f it up */ - // if (client instanceof ErisClient) { - // return ClientType.Eris; - // } +// try { +// const clientType = this.getClientType(client); - // return ClientType.Unknown; - // } -} +// switch (clientType) { +// case ClientType.DiscordJs: +// return new DiscordJsClientAdapter((client as DiscordJsClient)); +// case ClientType.Eris: +// Util.warn( +// `You are using an Eris client, some things may not work correctly. This is currently under experimental support and it is still recommended to use a discord.js client.`, +// 'ExperimentalClientInstance' +// ); +// // return new ErisClientAdapter((client as ErisClient)); +// throw new Error('Eris client is not supported yet'); +// default: +// throw new Error('Unsupported client type'); +// } +// } catch (error) { +// throw new Error(`Failed to create client adapter: ${error}`); +// } + + +/** old code just in case */ +// private static getClientType(client: SupportedClient): ClientType { +// if (client instanceof DiscordJsClient) { +// return ClientType.DiscordJs; +// } + +// if (client instanceof ErisClient) { +// return ClientType.Eris; +// } + +// return ClientType.Unknown; +// } diff --git a/packages/discord-player/src/clientadapter/ClientModeDetector.ts b/packages/discord-player/src/clientadapter/ClientModeDetector.ts index 0439e53cb..e40a77760 100644 --- a/packages/discord-player/src/clientadapter/ClientModeDetector.ts +++ b/packages/discord-player/src/clientadapter/ClientModeDetector.ts @@ -15,16 +15,16 @@ export const VALID_PACKAGES: ValidPackagesStructure[] = [ await import("discord.js") return true } catch { - return false + return false; } }, async testClient(client: SupportedClient) { try { const { Client } = await import("discord.js") - return client instanceof Client + return client instanceof Client; } catch { - return false + return false; } } }, @@ -35,28 +35,28 @@ export const VALID_PACKAGES: ValidPackagesStructure[] = [ await import("eris") return true } catch { - return false + return false; } }, async testClient(client) { try { const { Client } = await import("eris") - return client instanceof Client + return client instanceof Client; } catch { - return false + return false; } }, } -] +]; export async function detectClientMode(client: SupportedClient): Promise { for(const pkg of VALID_PACKAGES) { const isValid = await pkg.test() const isInstance = await pkg.testClient(client) - if(isValid && isInstance) return pkg.name + if (isValid && isInstance) return pkg.name; } - return "unknown" -} \ No newline at end of file + return "unknown"; +} diff --git a/packages/discord-player/src/clientadapter/IClientAdapter.ts b/packages/discord-player/src/clientadapter/IClientAdapter.ts index cf3220604..23a361cca 100644 --- a/packages/discord-player/src/clientadapter/IClientAdapter.ts +++ b/packages/discord-player/src/clientadapter/IClientAdapter.ts @@ -22,7 +22,7 @@ export const ClientType = { DiscordJS: "discord.js", Eris: "eris", Unknown: "unknown" -} as const +} as const; export type ClientType = typeof ClientType[keyof typeof ClientType]