Fix Kick module: handle URL input and wrap livestream error
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s

This commit is contained in:
2026-04-02 07:31:18 +00:00
parent ed2919224b
commit 845c292230

View File

@@ -50,15 +50,26 @@ export class KickManager {
if (!client) return { channel: null, livestream: null }; if (!client) return { channel: null, livestream: null };
try { try {
const channels = await client.channels.getChannels({ slug: [channelName] }) as KickChannel[]; let cleanChannelName = channelName.toLowerCase().replace(/^@/, '').replace(/^https?:\/\/kick\.com\//, '').trim();
if (cleanChannelName.length > 25) {
console.error(`[KICK] Channel name "${cleanChannelName}" exceeds 25 characters`);
return { channel: null, livestream: null };
}
const channels = await client.channels.getChannels({ slug: [cleanChannelName] }) as KickChannel[];
const channel = channels?.[0] || null; const channel = channels?.[0] || null;
if (!channel) return { channel: null, livestream: null }; if (!channel) return { channel: null, livestream: null };
const livestreams = await client.livestreams.getLivestreams({ let livestream: KickLivestream | null = null;
broadcaster_user_id: [channel.user_id] try {
}) as KickLivestream[]; const livestreams = await client.livestreams.getLivestreams({
const livestream = livestreams?.[0] || null; broadcaster_user_id: [channel.user_id]
}) as KickLivestream[];
livestream = livestreams?.[0] || null;
} catch (livestreamError) {
console.warn(`[KICK] Could not fetch livestream data for ${cleanChannelName}:`, livestreamError);
}
return { channel, livestream }; return { channel, livestream };
} catch (error) { } catch (error) {