> For the complete documentation index, see [llms.txt](https://discord-super-utils.gitbook.io/discord-super-utils/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://discord-super-utils.gitbook.io/discord-super-utils/managers/music-manager.md).

# Music Manager

This page shows you everything about Music Manager.

## **MusicManager**

**class discordSuperUtils.MusicManager(bot, spotify\_support=True, \*\*kwargs)**

Initializer for [**MusicManager**](/discord-super-utils/managers/music-manager.md#musicmanager); represents a music manager that can manage all music functions for the bot.

{% hint style="warning" %}
[**MusicManager** ](/discord-super-utils/managers/music-manager.md#musicmanager)requires [`FFMPEG`](https://www.ffmpeg.org) to be installed on host system.
{% endhint %}

| Attributes            | Methods             | Events               |
| --------------------- | ------------------- | -------------------- |
| **`bot`**             | **`fetch_data`**    | **`on_music_error`** |
| **`spotify_support`** | **`create_player`** |                      |
| **`spotify`**         | **`queue_remove`**  |                      |
| **`queue`**           | **`queue_add`**     |                      |
| **`client_id`**       | **`lyrics`**        |                      |
| **`client_secret`**   | **`play`**          |                      |
|                       | **`pause`**         |                      |
|                       | **`resume`**        |                      |
|                       | **`skip`**          |                      |
|                       | **`volume`**        |                      |
|                       | **`join`**          |                      |
|                       | **`leave`**         |                      |
|                       | **`history`**       |                      |
|                       | **`now_playing`**   |                      |
|                       | **`queueloop`**     |                      |
|                       | **`loop`**          |                      |

### Attributes

* **`bot` (commands.Bot)**&#x20;

  * Used so MusicManager can fetch bot attributes.
  * The bot object used for discord

* **`spotify_support` (bool)**

  * Toggles the spotify support for the music manager.

* **`spotify` (SpotifyClient)**

  * The spotify client of the music manager.

* **`queue` (Dict\[int, QueueManager])**

  * The queues of the guilds.

* **`client_id` (str)**

  * The client id of the spotify client.

* **`client_secret` (str)**
  * The client secret of the spotify client.

### Methods

* **`fetch_data(query: str)`**

  Fetches the youtube video by the query.<br>

  **Parameters**

  * **`query` (str)**

    * The youtube query.

  **Returns**

  * **dict**
    * YTDL Video data.<br>

* **`create_player(query: str)`**

  Creates a spotify or youtube player from the query\
  \
  **Parameters**

  * **`query` (str)**

    * The spotify or youtube query.

  **Returns**

  * **Player**
    * The spotify or YTDL song data.

* **`queue_remove(ctx, index)`**

  Removes a player at the specified index.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will remove the player from.
  * **`index` (int)**

    * The index of the player.

* **`queue_add(player, ctx)`**

  Adds the player to the queue\
  \
  Parameters

  * **`player` (Player)**
    * The player the music manager will add
  * **`ctx` (commands.Context)**

    * The context the music manager will add the player to.

* **`play(ctx, player=None)`**

  Plays the player given

  If no player is given music manager gets the next song in the queue\
  \
  **Paremeters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the next song from.
  * **`player` (Player)**

    * The player the music manager will play, gets the next song in the queue if it is not passed.

  **Returns**

  * **bool**

    * True if the player has been successfully played.

* **`lyrics(ctx, query=None)`**

  Gets the lyrics of the query if found.\
  Returns the lyrics of the currently playing song if query is not passed.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the currently playing song from.
  * **`query` (str)**

    * The query of the song.

  **Returns**

  * **str**
    * The lyrics of the song or None if not found.<br>

* **`pause(ctx)`**

  Pauses the currently playing player

  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the currently playing song from.<br>

  **Returns**

  * **bool**

    * True if the song was paused successfully.

* **`resume(ctx)`**

  Resumes the currently playing player

  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the currently playing song from.<br>

  **Returns**

  * **bool**
    * True if the song was resumed successfully.

* **`skip(ctx, index=None)`**

  Plays the player at the index specified.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the player from.
  * **`index` (int)**

    * The index of the player.

* **`volume(ctx, volume)`**

  Sets the volume of the players.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**
    * The context the music manager will get the players from.
  * **`volume` (int)**

    * The new volume

* **`join(ctx)`**

  Joins the voice channel of ctx\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will get the voice channel from.

* **`leave(ctx)`**

  Leaves the voice channel of ctx\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will get the voice channel from.

* **`now_playing(ctx)`**

  Returns the currently playing song.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will get the currently playing song from.

  **Returns**

  * **Player**

    * The currently playing song

* **`history(ctx)`**

  Returns the history of players.\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will get the history from.

  **Returns**

  * **List\[Player]**

    * The list of played players.

* **`queueloop(ctx)`**

  Toggles the queue loop\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will toggle the queue loop in.

  **Returns**

  * **bool**
    * queue loop is enabled

* **`loop(ctx)`**

  Toggles the loop\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will toggle the loop in.

  **Returns**

  * **bool**

    * loop is enabled

* **`get_queue(ctx)`**\
  Returns the queue of ctx\
  \
  **Parameters**

  * **`ctx` (commands.Context)**

    * The context the music manager will get the queue from.

  **Returns**

  * **List\[Player]**
    * The queue of ctx.
