#Tiktok-live-connector don’t work

11 messages · Page 1 of 1 (latest)

wraith hill

||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;

}
}

upper canyonBOT
tired sparrow

What about it doesn't work? Do you call that function anywhere, does any of the things in it happen (the console.log for example), ...?

wraith hill
wraith hill
tired sparrow

What about it doesn't work? [...] does any of the things in it happen?
If you want help please respond to everything asked, not just selectively

wraith hill

Nothing comes out in the logs. The bot starts and doesn’t send the notification when someone goes live

onyx cometBOT

If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
wraith hill
onyx comet If you aren't getting any errors, try to place `console.log` checkpoints through...

const connection = new TikTokConnection(username);
^

TypeError: TikTokConnection is not a constructor
at Object.startTikTokListener (C:\Users\Administrator\Desktop\Discord bot\notifichestream\streamNotify.js:119:24)
at Client.<anonymous> (C:\Users\Administrator\Desktop\Discord bot\index.js:92:16)
at Object.onceWrapper (node:events:633:26)
at Client.emit (node:events:518:28)
at WebSocketManager.triggerClientReady (C:\Users\Administrator\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:17)
at WebSocketManager.checkShardsReady (C:\Users\Administrator\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:367:10)
at WebSocketShard.<anonymous> (C:\Users\Administrator\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:197:16)
at WebSocketShard.emit (node:events:518:28)
at WebSocketShard.checkReady (C:\Users\Administrator\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:184:12)
at WebSocketShard.gotGuild (C:\Users\Administrator\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:158:10)

tired sparrow

I assume you got that error the whole time, would have helped people helping you if you said so from the start. Your code is completely wrong, that library you use never worked like that. Where did you get that code from? A hallucinating AI or dreamt up yourself?

spiral olive

I’d also like to add that you should make smaller bits of code, test them out and then continue writing more instead of writing hundreds of lines then running it to see if something works.

Given that you wrote this yourself