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

VoiceClient not working for me #904

Open
Dark-night45 opened this issue Sep 1, 2022 · 14 comments
Open

VoiceClient not working for me #904

Dark-night45 opened this issue Sep 1, 2022 · 14 comments
Assignees
Labels
awaiting confirmation The issue has been resolved, but awaits confirmation from the creator to confirm. bug voice windows Issue is Windows related

Comments

@Dark-night45
Copy link

Dark-night45 commented Sep 1, 2022

Environment

  • PHP Version:
    • 8.1.8
  • DiscordPHP Version:
    • 7.3.0

Description
I have problem with play music from file in voice
when i run command, bot joined to voice but no sound.
in console i don't get any error. also i use debug code but no error.
i have all requirements too but file not played in voice.

Code :

    $voiceChannel = $message->guild->channels->get('id', '922503052420849684');
    $discord->joinVoiceChannel($voiceChannel, false, false)->then(function (VoiceClient $vc) {
      echo "Music Played";
      $vc->playFile('gg.mp3'); //the file is in code folder and i try __DIR__ too
    });

Edit : Update discordphp version

@key2peace
Copy link
Collaborator

which operating system are you using for your bot?

@Dark-night45
Copy link
Author

Dark-night45 commented Oct 23, 2022

Windows 10 x64

@key2peace key2peace added windows Issue is Windows related and removed need more information labels Oct 23, 2022
@key2peace
Copy link
Collaborator

can you try again with current dev-master?

@SQKo SQKo added bug awaiting confirmation The issue has been resolved, but awaits confirmation from the creator to confirm. and removed need more information labels Nov 7, 2022
@Dark-night45
Copy link
Author

I use normal master
but now i updated it(v7.3.3) but my music file not played
also i tested dev-master, but with dev-master i can't run the bot and this is the error message i got :

PHP Fatal error:  Uncaught Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException: The option "pmChannels" does not exist. Defined options are: "cacheInterface", "cacheSweep", "disabledEvents", "dnsConfig", "intents", "loadAllMembers", "logger", "loop", "retrieveBans", "shardCount", "shardId", "socket_options", "storeMessages", "token". in C:\xampp\htdocs\back now\bot\vendor\symfony\options-resolver\OptionsResolver.php:871
Stack trace:
#0 C:\xampp\htdocs\back now\bot\vendor\team-reflex\discord-php\src\Discord\Discord.php(1422): Symfony\Component\OptionsResolver\OptionsResolver->resolve()
#1 C:\xampp\htdocs\back now\bot\vendor\team-reflex\discord-php\src\Discord\Discord.php(362): Discord\Discord->resolveOptions()
#2 C:\xampp\htdocs\back now\bot\index.php(44): Discord\Discord->__construct()
#3 {main}
  thrown in C:\xampp\htdocs\back now\bot\vendor\symfony\options-resolver\OptionsResolver.php on line 871

@SQKo
Copy link
Member

SQKo commented Nov 9, 2022

but with dev-master i can't run the bot and this is the error message i got :

Remove 'pmChannels' from your Discord options, it is no longer available in v10

$discord = new Discord([
    'pmChannels' => ... // remove this
]);

@Dark-night45
Copy link
Author

My bot run successfully
But no command worked and no error was displayed in the console

@key2peace
Copy link
Collaborator

is your bot verified? is the command a message one without mention or through slash? do you have message_content intent enabled?

@Dark-night45
Copy link
Author

My bot not verified, i don't have any slash command and message_content is enabled

@key2peace
Copy link
Collaborator

key2peace commented Dec 3, 2022

is it also enabled in the intents defined in the options for $discord = new Discord()? (See #905)

@Dark-night45
Copy link
Author

i see the following issue, but if my bot return empty, then why functions like join voice not working

@key2peace
Copy link
Collaborator

I don't have any such issues as you described above, also, in regards to joining a voice channel, nothing really changed, so this should simply work, even on your 7.3.3, show me your discord construct (without the token)

@Dark-night45
Copy link
Author

include __DIR__ . '/vendor/autoload.php';
require_once('secret.php');
$GLOBALS['prefix'] = '.';
$token = get_token();

$discord = new Discord([
  'token' => $token,
  'loadAllMembers' => false,
  'storeMessages' => false,
  // 'pmChannels' => false
  // 'dnsConfig' => '8.8.8.8'
]);

$discord->on('ready', function(Discord $discord){
  echo "Bot is online";
});
$discord->on('ready', function($discord) {
  $activity = $discord->factory(Activity::class, [
    'name' => 'KC',
    'type' => Activity::TYPE_COMPETING
  ]);
  $discord->updatePresence($activity, false, "idle", false);
});

$discord->on('error', function ($e) {
  echo emit('udp-error', [$e]);
});
$discord->run();

@bariscodefxy
Copy link

My bot run successfully But no command worked and no error was displayed in the console

@Dark-night45 Hello, I know it's late but I updated my Hiro-Bot and commands were not worked for me too. I fixed with adding intent, 'Intents::MESSAGE_CONTENT'.

Example from my bot:

$bot = new Hiro([
    'token' => $_ENV['TOKEN'],
    'prefix' => $_ENV['PREFIX'],
    'shardId' => $shard_id,
    'shardCount' => $shard_count,
    'caseInsensitiveCommands' => true,
    'loadAllMembers' => true,
    'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS | Intents::MESSAGE_CONTENT
]);

I'm seeing you're not using intents so you can fix that with adding this to array:

    'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS | Intents::MESSAGE_CONTENT

If you don't wanna to use GUILD_MEMBERS intent,

    'intents' => Intents::getDefaultIntents() | Intents::MESSAGE_CONTENT

this is works too.

@Steveb-p
Copy link

Steveb-p commented Mar 7, 2024

Had the same issue. Promise seemed stuck in an unresolved state after UDP connection was established (event listeners for the voice status change never fired). Updating the library to current dev-master resolved the issue.

Seems like those events are no longer emitted on version pre 10.0-RC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting confirmation The issue has been resolved, but awaits confirmation from the creator to confirm. bug voice windows Issue is Windows related
Projects
None yet
Development

No branches or pull requests

5 participants