Module Contents¶
Classes¶
The requested song data |
|
The class which acts a music controller/player |
|
The manager class to initiate and music and manage its player |
Functions¶
|
Formats the search string for the YouTube music search |
|
It returns required video data after searching YouTube |
|
It checks the music queue |
Attributes¶
- DiscordUtils.music.has_voice = True¶
- DiscordUtils.music.bug_reports_message¶
- exception DiscordUtils.music.EmptyQueue[source]¶
Bases:
Exception
Cannot skip because queue is empty
- exception DiscordUtils.music.NotConnectedToVoice[source]¶
Bases:
Exception
Cannot create the player because bot is not connected to voice
- exception DiscordUtils.music.NotPlaying[source]¶
Bases:
Exception
Cannot <do something> because nothing is being played
- await DiscordUtils.music.ytbettersearch(query)[source]¶
Formats the search string for the YouTube music search
- Return type
- class DiscordUtils.music.Song(source, url, title, description, views, duration, thumbnail, channel, channel_url, loop)[source]¶
The requested song data
- Parameters
- __slots__ = ['source', 'url', 'title', 'description', 'views', 'duration', 'thumbnail', 'channel',...¶
- await DiscordUtils.music.get_video_data(url, search, bettersearch, loop)[source]¶
It returns required video data after searching YouTube
- Raises
RuntimeError – Is raised when the package is install without the .[voice] parameters
- Returns
The song data in a formatted way
- Return type
- Parameters
- DiscordUtils.music.check_queue(ctx, opts, music, after, on_play, loop)[source]¶
It checks the music queue
- Parameters
ctx (commands.Context) – The commands context
opts (dict) – A set options for ffmpeg
music (Music) – The master class where the all the players data is stored
after (Callable) – The
check_queue()
which would be called afterwardson_play (MusicPlayer.on_play) –
MusicPlayer.on_play()
functionloop (Optional[asyncio.AbstractEventLoop]) – The event loop in which the
Bot
is running
- Raises
RuntimeError – Is raised when the package is install without the .[voice] parameters
- Return type
- class DiscordUtils.music.MusicPlayer(ctx, music, **kwargs)[source]¶
The class which acts a music controller/player
- Raises
RuntimeError – Is raised when the package is install without the .[voice] parameters
NotPlaying – See
skip()
,stop()
,resume()
,pause()
,toggle_song_loop()
,change_volume()
,remove_from_queue()
EmptyQueue – See
skip()
,current_queue()
- Parameters
ctx (discord.ext.commands.context.Context) –
music (Music) –
- __slots__ = ['ctx', 'voice', 'loop', 'music', 'after_func', 'on_play_func', 'on_queue_func', 'on_skip_func',...¶
- on_queue(self, func)[source]¶
The event when the song is queued
- Parameters
func (Callable) –
- Return type
- on_play(self, func)[source]¶
The event when the song is played
- Parameters
func (Callable) –
- Return type
- on_skip(self, func)[source]¶
The event when the song is skipped
- Parameters
func (Callable) –
- Return type
- on_stop(self, func)[source]¶
The event when the player is stopped
- Parameters
func (Callable) –
- Return type
- on_pause(self, func)[source]¶
The event when the song is paused
- Parameters
func (Callable) –
- Return type
- on_resume(self, func)[source]¶
The event when the song is resumed
- Parameters
func (Callable) –
- Return type
- on_loop_toggle(self, func)[source]¶
The event when the looping is enabled
- Parameters
func (Callable) –
- Return type
- on_volume_change(self, func)[source]¶
The event when the volume is changed
- Parameters
func (Callable) –
- Return type
- on_remove_from_queue(self, func)[source]¶
The event when the song is removed from the queue
- Parameters
func (Callable) –
- Return type
- await play(self)[source]¶
Determines which song to play from the queue
- Returns
See above
- Return type
- await skip(self, force=False)[source]¶
Skips the current song which is being played
- Parameters
force (bool, optional) – Force skip or not, defaults to False
- Raises
NotPlaying – When there is no song played then this error is raised
EmptyQueue – When the queue is empty
- Returns
It returns (old song, new song) or just (song) depending on the situtation
- Return type
- await stop(self)[source]¶
Stops the player
- Raises
NotPlaying – When nothing is played
- Return type
- await pause(self)[source]¶
Pauses the player
- Raises
NotPlaying – When nothing is played
- Returns
The song on which the pause was initiated
- Return type
- await resume(self)[source]¶
Resumes the player
- Raises
NotPlaying – When nothing was played by the player previously
- Returns
The song which will be played
- Return type
- current_queue(self)[source]¶
Gives the current queue of songs which is there in the player
- Raises
EmptyQueue – When the song queue is empty
- Returns
_description_
- Return type
Union[Iterable, Song]
- now_playing(self)[source]¶
Returns the
Song
which is currently being played- Returns
See above
- Return type
Optional[Union[Iterable, Song]]
- await toggle_song_loop(self)[source]¶
It toggles on/off the looping
- Raises
NotPlaying – When no song is being played
- Returns
The currently playing song or the looped queue
- Return type
Optional[Union[Iterable, Song]]
- await change_volume(self, vol)[source]¶
Change the song volume of the currently played song
- Parameters
vol (int) – The amount by the volume needs to increased or decreased
- Raises
NotPlaying – When no song is played
- Returns
(The song which is being played, volume no by which the song’s volume was increased or decreased)
- Return type
- await remove_from_queue(self, index)[source]¶
The utility function to remove
Song
from the queue- Parameters
- Raises
NotPlaying – When nothing is player by the player
- Returns
The song to be removed from the player
- Return type
- class DiscordUtils.music.Music[source]¶
The manager class to initiate and music and manage its player
- Raises
RuntimeError – Is raised when the package is install without the .[voice] parameters
- __slots__ = ['queue', 'players']¶
- create_player(self, ctx, **kwargs)[source]¶
It create a music player, using which the music will be played in the voice channels
- Parameters
ctx (commands.Context) – The commands context
- Raises
NotConnectedToVoice – When the client is not connect to any of the voice channel
- Returns
The music player using the user will have the control over its requested songs
- Return type
- get_player(self, **kwargs)[source]¶
Its gets the MusicPlayer of the specified guild or voice channel
- Returns
See above
- Return type
Optional[MusicPlayer]