Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await for create stream make stream never start #106

Open
Djahmo opened this issue Oct 17, 2024 · 1 comment
Open

await for create stream make stream never start #106

Djahmo opened this issue Oct 17, 2024 · 1 comment

Comments

@Djahmo
Copy link

Djahmo commented Oct 17, 2024

HI i have try 2 versions. One with await streamer.createStream() and one with streamer.createStream()

streamer.createStream() work

but await streamer.createStream() never recieve the promiss resolve so never go next on code

The actual code :

const fs = require('fs');
require('discord.js-selfbot-v13');
const { joinVoiceChannel, getVoiceConnection } = require('@discordjs/voice');

const connectToVoiceChannel = async (client, state = null) => {

const {Streamer} = await import('@dank074/discord-video-stream');
const streamer = new Streamer(client);

const db = require(../../db/${client.user.id}.json);
try {
const channelId = db.voiceconnect;
if (!channelId) {
console.error([${client.user.tag}] ID de canal vocal non spécifié dans le fichier de configuration.);
return;
}

const channel = await client.channels.fetch(channelId, { force: true }).catch(err => {
  console.error(`[${client.user.tag}] Erreur lors de la récupération du canal vocal:`, err);
});

if (!channel) {
  console.error(`[${client.user.tag}] Le canal vocal avec l'ID ${channelId} n'a pas été trouvé.`);
  return;
}

if (state)
  if (state.channelId && state.channelId !== channel.id)
    return;

if(db.voicewebcam) {
  client.user.setActivity({ name: 'PORNHUB EN FURIE', type: 'WATCHING' });
}

if(db.voicewebcam) {
  //Stream.signalVideo(channel.guild.id, channel.id, true, false, false);
}

streamer.joinVoice( channel.guild.id, channel.id)

if(db.voicestream) await streamer.createStream()

} catch (error) {
console.error([${client.user.tag}] Erreur lors de la connexion au canal vocal avec l'ID ${db.voiceconnect}:, error);
}
};

const handleVoiceStateUpdate = async (oldState, newState) => {
const client = newState.client;
if (oldState.member && oldState.member.id === client.user.id) {
console.log([${client.user.tag}] Déconnecté du canal vocal, reconnexion);
await connectToVoiceChannel(client, newState);
}
};

module.exports = {
name: "ready",
once: false,
run: async (client) => {
try {
if (!fs.existsSync(./db/${client.user.id}.json)) {
console.error([${client.user.tag}] Fichier de configuration non trouvé.);
return;
}
await connectToVoiceChannel(client);

  client.on('voiceStateUpdate', handleVoiceStateUpdate);

} catch (e) {
  console.error(`[${client.user.tag}] Erreur lors de l'exécution du script:`, e);
}

}
};

thx for help

@BitcircuitEU
Copy link

connectToVoiceChannel

did you use any of the example scripts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants