Code Monkey home page Code Monkey logo

nicobot's Issues

Multiple AudioPlayer instances running on a single voice client

This is happening due to the flawed voice structure:

  1. Voice connection is established in GuildVoiceChannel.connect() call, meaning that new instance will be spawned only when the connection was established on behalf of the code.
  2. This makes the library uncapable of responding to unexpected changes- such as gateway connection loss or forced channel moving. Voice client will disconnect, leaving AudioPlayer behind.
  3. AudioPlayer is designed to be independent, so it doesn't die with VoiceClient together. Instead, It will start to wait for the new client to appear, and attach to it when found. Which doesn't work as intended, since unexpected changes won't trigger new voice client to be initialized.
  4. So AudioPlayer will keep on floating until client connects to the voice channel again. and when the other player sends speak, both AudioPlayer will play to the same client, resulting in horrible sound mixture. this carries on until the old AudioPlayer has its source exhausted and eventually stops playing. even then, the thread stays alive.

If you repeat playing, kicking the bot and rejoining it, you could combine more than 2 players.

Although this can be handled within user codes, major changes should be made in the library regardless to fix the flaws.

  1. Change the VoiceClient initlalizing process independent of channel.py
  • This should be done within the scope of gateway code, and no other threads should work on this.
  1. Possibly enable re-initialization of VoiceClient
  • This eliminates the need of transferring to new client for players, but possibly requires changing the structure of existing WebSocketClient.
  1. Improve the failsafe measures in AudioPlayer
  • A way to kill the idling orphan player should be made.

TODO list

  • Change default value of API calls to an object that states EMPTY, and use a function that remove parameters with it from the postdata.
  • Refactor SelectableEvent to Event object to support Windows- which doesn't support selecting non-socket fd.
  • Unify putdata, getdata, patchdata to postdata
  • Implement Rate limit handler
  • add private send_request method to each client to eliminate the unnecessary multiple usage of f-strings in API request.
  • Implement handler
  • Implement AudioPlayer, AudioSource class
  • Write docstring to necessary components
  • Add File object to centralize the way of handling files in HTTP API request
  • Refactor Guild event handling part
  • Add embed
  • Refactor methods to accept embed object
  • properly fix heartbeat thread
  • Rewrite Rate limit handler to prevent 429
  • Support slash command
  • Separate the repo from NicoBot
  • Make Docs

==================== Beta release ====================

  • Implement resuming for voice clients
  • Write tests ffs
  • Change type handling to enum
  • Add support to chat threads?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.