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
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user