||guys I was programming a bot for discord in discord js that sends the notification on a discord channel every time someone in a streamer list goes live like notifyMe does. As a bee I used tiktok-live-conncector but it doesn’t go.
const { TikTokConnection } = require('tiktok-live-connector');
const notificatiTiktok = {};
async function startTikTokListener(client) {
for (const username of tiktokStreamers) {
const connection = new TikTokConnection(username);
connection.on('connected', () => {
console.log(`[TIKTOK] Connesso a ${username}`);
});
connection.on('streamStarted', async () => {
if (notificatiTiktok[username]) return; // Già notificato per questa sessione live
notificatiTiktok[username] = true;
try {
const embed = new EmbedBuilder()
.setTitle(`${username} è in diretta su TikTok!`)
.setDescription(`[Clicca qui per guardare](https://www.tiktok.com/@${username}/live)`)
.setColor('#000000')
.setFooter({ text: '🔴 TikTok Live' });
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel('Guarda Stream')
.setStyle(ButtonStyle.Link)
.setURL(`https://www.tiktok.com/@${username}/live`)
);
const channel = await client.channels.fetch(TIKTOK_CHANNEL_ID);
await channel.send({ embeds: [embed], components: [row] });
} catch (error) {
console.error(`Errore durante la notifica live TikTok per ${username}:`, error);
}
});
connection.on('streamEnded', () => {
console.log(`[TIKTOK] ${username} ha terminato la live`);
notificatiTiktok[username] = false; // Pronto a notificare la prossima live
});
connection.connect().catch(err => {
console.error(`[TIKTOK] Errore connessione ${username}:`, err.message);
});
connectionsTiktok[username] = connection;
}
}