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 @@