📄️ Introduction
Player preconditions are used to check certain conditions before a player can be retrieved. This can be used to ensure that the user is connected to a voice channel before a player can be retrieved, or that the user is in the same voice channel as the bot, the player is in a certain state, a track is playing, or not, and much more.
📄️ Using player preconditions
For example, if you write a pause command for your music bot. Most users want to send a message if the player is already paused. We can use a precondition to ensure that the player is in the correct state before retrieving it, here we can use the NotPaused precondition to ensure the player is not paused.
📄️ Handling precondition failures
A great feature of player preconditions is that they provide a centralized way to ensure that the player is in a certain state without having to write the same checks over and over again. However, if a precondition fails, the player will not be retrieved and an error will be returned. This error needs to be handled, otherwise the user will not know why the command failed.