diff --git a/docs/conf.py b/docs/conf.py index 3c0484cc..fd19973e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,6 +21,7 @@ import re import sys + sys.path.insert(0, os.path.abspath(".")) sys.path.insert(0, os.path.abspath("..")) sys.path.append(os.path.abspath("extensions")) diff --git a/docs/extensions/attributetable.py b/docs/extensions/attributetable.py index 5640a7ed..3f0ec89e 100644 --- a/docs/extensions/attributetable.py +++ b/docs/extensions/attributetable.py @@ -3,7 +3,8 @@ import importlib import inspect import re -from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Sequence, Tuple +from collections.abc import Sequence +from typing import TYPE_CHECKING, NamedTuple from docutils import nodes from sphinx import addnodes @@ -13,6 +14,7 @@ from sphinx.util.docutils import SphinxDirective from sphinx.util.typing import OptionSpec + if TYPE_CHECKING: from .builder import DPYHTML5Translator @@ -96,7 +98,7 @@ class PyAttributeTable(SphinxDirective): final_argument_whitespace = False option_spec: OptionSpec = {} - def parse_name(self, content: str) -> Tuple[str, str]: + def parse_name(self, content: str) -> tuple[str, str]: match = _name_parser_regex.match(content) if match is None: raise RuntimeError(f"content {content} somehow doesn't match regex in {self.env.docname}.") @@ -112,7 +114,7 @@ def parse_name(self, content: str) -> Tuple[str, str]: return modulename, name - def run(self) -> List[attributetableplaceholder]: + def run(self) -> list[attributetableplaceholder]: """If you're curious on the HTML this is meant to generate:
@@ -149,7 +151,7 @@ def run(self) -> List[attributetableplaceholder]: return [node] -def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]: +def build_lookup_table(env: BuildEnvironment) -> dict[str, list[str]]: # Given an environment, load up a lookup table of # full-class-name: objects result = {} @@ -178,7 +180,7 @@ def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]: class TableElement(NamedTuple): fullname: str label: str - badge: Optional[attributetablebadge] + badge: attributetablebadge | None def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) -> None: @@ -203,12 +205,12 @@ def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) - def get_class_results( - lookup: Dict[str, List[str]], modulename: str, name: str, fullname: str -) -> Dict[str, List[TableElement]]: + lookup: dict[str, list[str]], modulename: str, name: str, fullname: str +) -> dict[str, list[TableElement]]: module = importlib.import_module(modulename) cls = getattr(module, name) - groups: Dict[str, List[TableElement]] = { + groups: dict[str, list[TableElement]] = { _("Attributes"): [], _("Methods"): [], } diff --git a/docs/wavelink.rst b/docs/wavelink.rst index 633fe471..73eaf0ba 100644 --- a/docs/wavelink.rst +++ b/docs/wavelink.rst @@ -34,6 +34,19 @@ An event listener in a cog. This event can be called many times throughout your bots lifetime, as it will be called when Wavelink successfully reconnects to your node in the event of a disconnect. +.. function:: on_wavelink_node_disconnected(payload: wavelink.NodeDisconnectedEventPayload) + + Called when a Node has disconnected/lost connection to wavelink. **This is NOT** the same as a node being closed. + This event will however be called directly before the :func:`on_wavelink_node_closed` event. + + The default behaviour is for wavelink to attempt to reconnect a disconnected Node. This event can change that + behaviour. If you want to close this node completely see: :meth:`Node.close` + + This event can be used to manage currrently connected players to this Node. + See: :meth:`Player.switch_node` + + .. versionadded:: 3.5.0 + .. function:: on_wavelink_stats_update(payload: wavelink.StatsEventPayload) Called when the ``stats`` OP is received by Lavalink. @@ -128,6 +141,11 @@ Types tracks: wavelink.Search = await wavelink.Playable.search("Ocean Drive") +.. attributetable:: PlayerBasicState + +.. autoclass:: PlayerBasicState + + Payloads --------- @@ -136,6 +154,11 @@ Payloads .. autoclass:: NodeReadyEventPayload :members: +.. attributetable:: NodeDisconnectedEventPayload + +.. autoclass:: NodeDisconnectedEventPayload + :members: + .. attributetable:: TrackStartEventPayload .. autoclass:: TrackStartEventPayload @@ -442,6 +465,8 @@ Exceptions Exception raised when a :class:`Node` is tried to be retrieved from the :class:`Pool` without existing, or the ``Pool`` is empty. + This exception is also raised when providing an invalid node to :meth:`Player.switch_node`. + .. py:exception:: LavalinkException Exception raised when Lavalink returns an invalid response. diff --git a/wavelink/exceptions.py b/wavelink/exceptions.py index 7d395d0e..0069b11e 100644 --- a/wavelink/exceptions.py +++ b/wavelink/exceptions.py @@ -82,6 +82,8 @@ class AuthorizationFailedException(WavelinkException): class InvalidNodeException(WavelinkException): """Exception raised when a :class:`Node` is tried to be retrieved from the :class:`Pool` without existing, or the ``Pool`` is empty. + + This exception is also raised when providing an invalid node to :meth:`~wavelink.Player.switch_node`. """