From 845c2922306e57f163d06c65af59829a49ffd13b Mon Sep 17 00:00:00 2001 From: coding Date: Thu, 2 Apr 2026 07:31:18 +0000 Subject: [PATCH] Fix Kick module: handle URL input and wrap livestream error --- src/structures/KickManager.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/structures/KickManager.ts b/src/structures/KickManager.ts index 7188f36..5fffe75 100644 --- a/src/structures/KickManager.ts +++ b/src/structures/KickManager.ts @@ -50,15 +50,26 @@ export class KickManager { if (!client) return { channel: null, livestream: null }; 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; if (!channel) return { channel: null, livestream: null }; - const livestreams = await client.livestreams.getLivestreams({ - broadcaster_user_id: [channel.user_id] - }) as KickLivestream[]; - const livestream = livestreams?.[0] || null; + let livestream: KickLivestream | null = null; + try { + const livestreams = await client.livestreams.getLivestreams({ + 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 }; } catch (error) {