mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-01 20:42:50 +08:00
fix(api-server): handle QQ Music API export differences across versions
The @sansenjian/qq-music-api module's export structure varies between versions (2.2.10 vs 2.2.11+). Add fallback chain to find the Koa app: try candidate.listen first, then candidate.default.listen. Also resolve leftover merge conflict marker in instance.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0408f6ce3c
commit
4406eeacbe
2 files changed
+8
-3
No files matched your search
@@ -61,11 +61,9 @@ export class BotInstance extends EventEmitter {
|
||||
private disconnectEmitted = false;
|
||||
private voteSkipUsers = new Set<string>();
|
||||
private isAdvancing = false;
|
||||
<<<<<<< HEAD
|
||||
private idleTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private channelUserCount = 0;
|
||||
private profileManager: BotProfileManager;
|
||||
>>>>>>> origin/main
|
||||
|
||||
constructor(options: BotInstanceOptions) {
|
||||
super();
|
||||
|
||||
@@ -76,7 +76,14 @@ export function createApiServerManager(
|
||||
);
|
||||
} else {
|
||||
const qqModule = (await import("@sansenjian/qq-music-api")) as any;
|
||||
const koaApp = qqModule.default ?? qqModule;
|
||||
// The module's export structure varies between versions:
|
||||
// 2.2.11+: default → Koa app (has .listen)
|
||||
// 2.2.10: default → wrapper object whose .default is the Koa app
|
||||
// older: module itself may be the Koa app
|
||||
const candidate = qqModule.default ?? qqModule;
|
||||
const koaApp = typeof candidate.listen === "function"
|
||||
? candidate
|
||||
: candidate.default ?? null;
|
||||
if (koaApp && typeof koaApp.listen === "function") {
|
||||
qqMusicServer = await new Promise<Server>((resolve, reject) => {
|
||||
const srv = koaApp.listen(options.qqMusicPort, "127.0.0.1", () =>
|
||||
|
||||
Reference in new issue
Block a user