Skip to content

[Question]: How to gracefully disconnect from a voice channel #13

@nullpat

Description

@nullpat

FastLink version

2.4.1-rc.1

Description

player.destroy();

this leaves the bot connected to a voice channel

  const payload = {
    op: 4,
    d: {
      guild_id: guildId,
      channel_id: null,
      self_mute: false,
      self_deaf: false,
    },
  };
  client.guilds.cache.get(guildId).shard.send(payload);

setting channel_id here to null successfully disconnects the bot from the voice channel, however the bot has a 50% chance of blowing up with Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'queue') at update (\node_modules\@performanc\fastlink\index.js:248:29) when trying to add a song to the queue after creating and connecting the player again. Feels like there is a race condition somewhere

  1. player.destroy();
  2. send disconnectPayload (channel_id set to null)
  3. player.createPlayer();
  4. player.connect
  5. add something to queue (sometimes blows up here on first pass, sometimes i repeat 1-5 again then it blows up)

How would you recommend disconnecting the bot from a voice channel? I'm not sure if im missing something obvious

Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnot confirmedThis issue or pull request is not confirmed to be done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions