Skip to content

Commit

Permalink
Fix & document set_filters & from_filters (#289)
Browse files Browse the repository at this point in the history
Changed to use the properly typed keys

Changes to be committed:
	modified:   wavelink/filters.py
  • Loading branch information
TrapDrap authored Mar 22, 2024
1 parent 66a1c9d commit db0aa3b
Showing 1 changed file with 59 additions and 6 deletions.
65 changes: 59 additions & 6 deletions wavelink/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,38 @@ def _set_with_reset(self, filters: FiltersOptions) -> None:
self._vibrato = filters.get("vibrato", Vibrato({}))
self._rotation = filters.get("rotation", Rotation({}))
self._distortion = filters.get("distortion", Distortion({}))
self._channel_mix = filters.get("channelMix", ChannelMix({}))
self._low_pass = filters.get("lowPass", LowPass({}))
self._channel_mix = filters.get("channel_mix", ChannelMix({}))
self._low_pass = filters.get("low_pass", LowPass({}))

def set_filters(self, **filters: Unpack[FiltersOptions]) -> None:
# TODO: document this later maybe?
"""Set multiple filters at once to a standalone Filter object.
To set the filters to the player directly see :meth:`wavelink.Player.set_filters`
Parameters
----------
volume: float
The Volume filter to apply to the player.
equalizer: :class:`wavelink.Equalizer`
The Equalizer filter to apply to the player.
karaoke: :class:`wavelink.Karaoke`
The Karaoke filter to apply to the player.
timescale: :class:`wavelink.Timescale`
The Timescale filter to apply to the player.
tremolo: :class:`wavelink.Tremolo`
The Tremolo filter to apply to the player.
vibrato: :class:`wavelink.Vibrato`
The Vibrato filter to apply to the player.
rotation: :class:`wavelink.Rotation`
The Rotation filter to apply to the player.
distortion: :class:`wavelink.Distortion`
The Distortion filter to apply to the player.
channel_mix: :class:`wavelink.ChannelMix`
The ChannelMix filter to apply to the player.
low_pass: :class:`wavelink.LowPass`
The LowPass filter to apply to the player.
reset: bool
Whether to reset all filters that were not specified.
"""

reset: bool = filters.get("reset", False)
if reset:
Expand All @@ -699,8 +726,8 @@ def set_filters(self, **filters: Unpack[FiltersOptions]) -> None:
self._vibrato = filters.get("vibrato", self._vibrato)
self._rotation = filters.get("rotation", self._rotation)
self._distortion = filters.get("distortion", self._distortion)
self._channel_mix = filters.get("channelMix", self._channel_mix)
self._low_pass = filters.get("lowPass", self._low_pass)
self._channel_mix = filters.get("channel_mix", self._channel_mix)
self._low_pass = filters.get("low_pass", self._low_pass)

def _reset(self) -> None:
self._volume = None
Expand All @@ -723,7 +750,33 @@ def reset(self) -> None:

@classmethod
def from_filters(cls, **filters: Unpack[FiltersOptions]) -> Self:
# TODO: document this later maybe?
"""Creates a Filters object with specified filters.
Parameters
----------
volume: float
The Volume filter to apply to the player.
equalizer: :class:`wavelink.Equalizer`
The Equalizer filter to apply to the player.
karaoke: :class:`wavelink.Karaoke`
The Karaoke filter to apply to the player.
timescale: :class:`wavelink.Timescale`
The Timescale filter to apply to the player.
tremolo: :class:`wavelink.Tremolo`
The Tremolo filter to apply to the player.
vibrato: :class:`wavelink.Vibrato`
The Vibrato filter to apply to the player.
rotation: :class:`wavelink.Rotation`
The Rotation filter to apply to the player.
distortion: :class:`wavelink.Distortion`
The Distortion filter to apply to the player.
channel_mix: :class:`wavelink.ChannelMix`
The ChannelMix filter to apply to the player.
low_pass: :class:`wavelink.LowPass`
The LowPass filter to apply to the player.
reset: bool
Whether to reset all filters that were not specified.
"""

self = cls()
self._set_with_reset(filters)
Expand Down

0 comments on commit db0aa3b

Please sign in to comment.