diff --git a/docs/conf.py b/docs/conf.py index 627b1dc2..6a95660f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,6 +46,16 @@ "sphinxcontrib.asyncio", "sphinx.ext.intersphinx", "attributetable", + "sphinxext.opengraph" +] + +# OpenGraph Meta Tags +ogp_image = "https://raw.githubusercontent.com/PythonistaGuild/Wavelink/master/logo.png" +ogp_description = "Documentation for Wavelink, the Powerful Lavalink wrapper for discord.py." +ogp_site_url = "https://wavelink.dev/" +ogp_custom_meta_tags = [ + '', + '' ] # Add any paths that contain templates here, relative to this directory. @@ -101,7 +111,15 @@ # source_suffix = ['.rst', '.md'] source_suffix = ".rst" -intersphinx_mapping = {"py": ("https://docs.python.org/3", None)} +intersphinx_mapping = { + "py": ("https://docs.python.org/3", None), + "dpy": ("https://discordpy.readthedocs.io/en/stable/", None) +} + +extlinks = { + 'wlissue': ('https://github.com/PythonistaGuild/Wavelink/issues/%s', 'GH-%s'), + 'ddocs': ('https://discord.com/developers/docs/%s', None), +} pygments_style = "sphinx" pygments_dark_style = "monokai" \ No newline at end of file diff --git a/docs/ext/spotify.rst b/docs/ext/spotify.rst new file mode 100644 index 00000000..485cced7 --- /dev/null +++ b/docs/ext/spotify.rst @@ -0,0 +1,99 @@ +.. currentmodule:: wavelink.ext.spotify + + +Intro +----- +The Spotify extension is a QoL extension that helps in searching for and queueing tracks from Spotify URL's or ID's. To get started create a :class:`~SpotifyClient` and pass in your credentials. You then pass this to your :class:`wavelink.Node`'s. + +An example: + +.. code-block:: python3 + + import discord + import wavelink + from discord.ext import commands + from wavelink.ext import spotify + + + class Bot(commands.Bot): + + def __init__(self) -> None: + intents = discord.Intents.default() + intents.message_content = True + + super().__init__(intents=intents, command_prefix='?') + + async def on_ready(self) -> None: + print(f'Logged in {self.user} | {self.user.id}') + + async def setup_hook(self) -> None: + sc = spotify.SpotifyClient( + client_id='CLIENT_ID', + client_secret='CLIENT_SECRET' + ) + + node: wavelink.Node = wavelink.Node(uri='http://127.0.0.1:2333', password='youshallnotpass') + await wavelink.NodePool.connect(client=self, nodes=[node], spotify=sc) + + + bot = Bot() + + + @bot.command() + @commands.is_owner() + async def play(ctx: commands.Context, *, search: str) -> None: + + try: + vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player) + except discord.ClientException: + vc: wavelink.Player = ctx.voice_client + + vc.autoplay = True + + track: spotify.SpotifyTrack = await spotify.SpotifyTrack.search(search) + + if not vc.is_playing(): + await vc.play(track, populate=True) + else: + await vc.queue.put_wait(track) + + +Helpers +------- +.. autofunction:: decode_url + + +Client +------ +.. attributetable:: SpotifyClient + +.. autoclass:: SpotifyClient + :members: + + +Enums +----- +.. attributetable:: SpotifySearchType + +.. autoclass:: SpotifySearchType + :members: + + +Spotify Tracks +-------------- +.. attributetable:: SpotifyTrack + +.. autoclass:: SpotifyTrack + :members: + + +Exceptions +---------- +.. py:exception:: SpotifyRequestError + + Base error for Spotify requests. + + status: :class:`int` + The status code returned from the request. + reason: Optional[:class:`str`] + The reason the request failed. Could be ``None``. diff --git a/docs/index.rst b/docs/index.rst index 8415f516..2968f44a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -44,16 +44,14 @@
Wavelink Reference:
Wavelink Extension API's:
@@ -75,6 +73,14 @@ recipes +.. rst-class:: index-display-none +.. toctree:: + :maxdepth: 1 + :caption: Spotify Extension + + ext/spotify + + .. rst-class:: index-display-none .. toctree:: :maxdepth: 1 diff --git a/docs/requirements.txt b/docs/requirements.txt index a7878e46..45913194 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,4 +5,5 @@ sphinxcontrib-asyncio sphinxcontrib-websupport Pygments furo -discord.py>=1.7.3 \ No newline at end of file +discord.py>=2.0.1 +sphinxext-opengraph \ No newline at end of file diff --git a/docs/wavelink.rst b/docs/wavelink.rst index e0987433..c52afb54 100644 --- a/docs/wavelink.rst +++ b/docs/wavelink.rst @@ -55,6 +55,34 @@ Payloads :members: +Enums +----- +.. attributetable:: NodeStatus + +.. autoclass:: NodeStatus + :members: + +.. attributetable:: TrackSource + +.. autoclass:: TrackSource + :members: + +.. attributetable:: LoadType + +.. autoclass:: LoadType + :members: + +.. attributetable:: TrackEventType + +.. autoclass:: TrackEventType + :members: + +.. attributetable:: DiscordVoiceCloseType + +.. autoclass:: DiscordVoiceCloseType + :members: + + Abstract Base Classes --------------------- .. attributetable:: wavelink.tracks.Playable @@ -159,52 +187,52 @@ Queues Filters ------- -.. attributeable:: Filter +.. attributetable:: Filter .. autoclass:: Filter :members: -.. attributeable:: Equalizer +.. attributetable:: Equalizer .. autoclass:: Equalizer :members: -.. attributeable:: Karaoke +.. attributetable:: Karaoke .. autoclass:: Karaoke :members: -.. attributeable:: Timescale +.. attributetable:: Timescale .. autoclass:: Timescale :members: -.. attributeable:: Tremolo +.. attributetable:: Tremolo .. autoclass:: Tremolo :members: -.. attributeable:: Vibrato +.. attributetable:: Vibrato .. autoclass:: Vibrato :members: -.. attributeable:: Rotation +.. attributetable:: Rotation .. autoclass:: Rotation :members: -.. attributeable:: Distortion +.. attributetable:: Distortion .. autoclass:: Distortion :members: -.. attributeable:: ChannelMix +.. attributetable:: ChannelMix .. autoclass:: ChannelMix :members: -.. attributeable:: LowPass +.. attributetable:: LowPass .. autoclass:: LowPass :members: @@ -214,9 +242,40 @@ Exceptions ---------- .. py:exception:: WavelinkException + + Base wavelink exception. + .. py:exception:: AuthorizationFailed + + Exception raised when password authorization failed for this Lavalink node. + .. py:exception:: InvalidNode + .. py:exception:: InvalidLavalinkVersion + + Exception raised when you try to use wavelink 2 with a Lavalink version under 3.7. + .. py:exception:: InvalidLavalinkResponse + + Exception raised when wavelink receives an invalid response from Lavalink. + + status: :class:`int` | :class:`None` + The status code. Could be :class:`None`. + .. py:exception:: NoTracksError + + Exception raised when no tracks could be found. + .. py:exception:: QueueEmpty + + Exception raised when you try to retrieve from an empty queue. + +.. py:exception:: InvalidChannelStateError + + Base exception raised when an error occurs trying to connect to a :class:`discord.VoiceChannel`. + +.. py:exception:: InvalidChannelPermissions + + Exception raised when the client does not have correct permissions to join the channel. + + Could also be raised when there are too many users already in a user limited channel.