aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
751 stars 160 forks source link

voiceStateUpdate event incorrectly returns true for both oldState and newState.streaming when stopping a stream #1236

Open Jaro-c opened 1 month ago

Jaro-c commented 1 month ago

Which package has the bugs?

The core library

Issue description

I'm encountering an issue with the voiceStateUpdate event in discord.js-selfbot-v13@3.3.0. The problem occurs specifically when trying to detect changes in a user's streaming state. Below is a detailed explanation of the issue:

  1. Joining a Voice Channel:

    • When a user joins a voice channel, both oldState.streaming and newState.streaming are null. This is the expected behavior.
  2. Starting a Stream:

    • When the user starts streaming, oldState.streaming is null, and newState.streaming correctly returns true, which is the expected behavior.
  3. Stopping the Stream:

    • However, when the user stops streaming, both oldState.streaming and newState.streaming incorrectly return true.

Code sample

client.on("voiceStateUpdate", async (oldState, newState) => {
    console.info(oldState.streaming, newState.streaming);
});

Package version

discord.js-selfbot-v13@3.3.0

Node.js version

v20.13.1

Operating system

Windows 11

Priority this issue should have

Medium (should be fixed soon)

Checklist

Additional Information

No response

aiko-chan-ai commented 4 weeks ago

There might have been an error; I'll check it later (this weekend).

002-sans commented 2 weeks ago

I try to do some code. For me everything work.

client.on('voiceStateUpdate', (oldState, newState) => {
    if (!oldState.channel && newState.channel) console.log(`${newState.user.username} has joined a voice channel`);
    else if (oldState.channel && !newState.channel) console.log(`${oldState.user.username} left a channel`);

    else if (!oldState.streaming && newState.streaming) console.log(`${newState.user.username} start a stream`)
    else if (oldState.streaming && !newState.streaming) console.log(`${oldState.user.username} stop a stream`)
})
Jaro-c commented 2 weeks ago

I try to do some code. For me everything work.

client.on('voiceStateUpdate', (oldState, newState) => {
    if (!oldState.channel && newState.channel) console.log(`${newState.user.username} has joined a voice channel`);
    else if (oldState.channel && !newState.channel) console.log(`${oldState.user.username} left a channel`);

    else if (!oldState.streaming && newState.streaming) console.log(`${newState.user.username} start a stream`)
    else if (oldState.streaming && !newState.streaming) console.log(`${oldState.user.username} stop a stream`)
})

It seems like you might be using a different version of the library because the code you shared doesn’t seem to work as expected in the version I’m using (3.3.0).

If you want to give it a try, I’m currently using version 3.3.0 of discord.js-selfbot-v13. Here’s an example you can test:

const { Client } = require("discord.js-selfbot-v13");

const client = new Client({ presence: { status: "invisible" } });

// Event: Voice Streaming
client.on("voiceStateUpdate", async (oldState, newState) => {
    console.log(oldState.streaming, "|", newState.streaming);
});

client.login("YOUR_TOKEN_HERE");

This should print true | true when someone stops streaming in the channel.

002-sans commented 2 weeks ago

Ofc i was using the latest version, but yea you're right. It log true | true when stopping streaming and leaving the channel.

aiko-chan-ai commented 2 weeks ago

sorry, I've been busy with college admissions lately ;-;