add function to clear filters on all tracks
This commit is contained in:
parent
1e12d79d68
commit
e504088da1
|
|
@ -27,6 +27,7 @@ from .events import *
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .filters import *
|
from .filters import *
|
||||||
from .objects import *
|
from .objects import *
|
||||||
|
from .queue import *
|
||||||
from .player import Player
|
from .player import Player
|
||||||
from .pool import *
|
from .pool import *
|
||||||
from .queue import *
|
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,6 @@ class LowPass(Filter):
|
||||||
"""Filter which supresses higher frequencies and allows lower frequencies to pass.
|
"""Filter which supresses higher frequencies and allows lower frequencies to pass.
|
||||||
You can also do this with the Equalizer filter, but this is an easier way to do it.
|
You can also do this with the Equalizer filter, but this is an easier way to do it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, tag: str, smoothing: float = 20):
|
def __init__(self, *, tag: str, smoothing: float = 20):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ from .exceptions import FilterInvalidArgument, FilterTagAlreadyInUse, FilterTagI
|
||||||
from .filters import Filter
|
from .filters import Filter
|
||||||
from .objects import Track
|
from .objects import Track
|
||||||
from .pool import Node, NodePool
|
from .pool import Node, NodePool
|
||||||
|
from .queue import Queue
|
||||||
|
|
||||||
class Filters:
|
class Filters:
|
||||||
"""Helper class for filters"""
|
"""Helper class for filters"""
|
||||||
|
|
@ -55,6 +56,7 @@ class Filters:
|
||||||
self._filters = []
|
self._filters = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_payloads(self):
|
def get_all_payloads(self):
|
||||||
"""Returns a formatted dict of all the filter payloads"""
|
"""Returns a formatted dict of all the filter payloads"""
|
||||||
payload = {}
|
payload = {}
|
||||||
|
|
@ -373,7 +375,7 @@ class Player(VoiceProtocol):
|
||||||
self._volume = volume
|
self._volume = volume
|
||||||
return self._volume
|
return self._volume
|
||||||
|
|
||||||
async def add_filter(self, filter: Filter, fast_apply=False) -> Filter:
|
async def add_filter(self, filter: Filter, fast_apply: bool = False) -> Filter:
|
||||||
"""Adds a filter to the player. Takes a pomice.Filter object.
|
"""Adds a filter to the player. Takes a pomice.Filter object.
|
||||||
This will only work if you are using a version of Lavalink that supports filters.
|
This will only work if you are using a version of Lavalink that supports filters.
|
||||||
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -389,7 +391,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
return self._filters
|
return self._filters
|
||||||
|
|
||||||
async def remove_filter(self, filter_tag: str, fast_apply=False) -> Filter:
|
async def remove_filter(self, filter_tag: str, fast_apply: bool = False) -> Filter:
|
||||||
"""Removes a filter from the player. Takes a filter tag.
|
"""Removes a filter from the player. Takes a filter tag.
|
||||||
This will only work if you are using a version of Lavalink that supports filters.
|
This will only work if you are using a version of Lavalink that supports filters.
|
||||||
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -405,7 +407,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
return self._filters
|
return self._filters
|
||||||
|
|
||||||
async def reset_filters(self, *, fast_apply=False):
|
async def reset_filters(self, *, fast_apply: bool = False):
|
||||||
"""Resets all currently applied filters to their default parameters.
|
"""Resets all currently applied filters to their default parameters.
|
||||||
You must have filters applied in order for this to work.
|
You must have filters applied in order for this to work.
|
||||||
If you would like the filters to be removed instantly, set the `fast_apply` arg to `True`.
|
If you would like the filters to be removed instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -419,6 +421,8 @@ class Player(VoiceProtocol):
|
||||||
)
|
)
|
||||||
self._filters.reset_filters()
|
self._filters.reset_filters()
|
||||||
await self._node.send(op="filters", guildId=str(self.guild.id))
|
await self._node.send(op="filters", guildId=str(self.guild.id))
|
||||||
|
|
||||||
|
|
||||||
if fast_apply:
|
if fast_apply:
|
||||||
await self.seek(self.position)
|
await self.seek(self.position)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from .exceptions import QueueEmpty, QueueException, QueueFull
|
||||||
|
|
||||||
|
|
||||||
class Queue(Iterable[Track]):
|
class Queue(Iterable[Track]):
|
||||||
|
"""Queue for Pomice. This queue takes pomice.Track as an input and includes looping and shuffling."""
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
max_size: Optional[int] = None,
|
max_size: Optional[int] = None,
|
||||||
|
|
@ -24,7 +25,7 @@ class Queue(Iterable[Track]):
|
||||||
overflow: bool = True,
|
overflow: bool = True,
|
||||||
):
|
):
|
||||||
self.max_size: Optional[int] = max_size
|
self.max_size: Optional[int] = max_size
|
||||||
self._queue = [] # type: ignore
|
self._queue: List[Track] = [] # type: ignore
|
||||||
self._overflow: bool = overflow
|
self._overflow: bool = overflow
|
||||||
self._loop_mode: Optional[LoopMode] = None
|
self._loop_mode: Optional[LoopMode] = None
|
||||||
self._current_item: Optional[Track] = None
|
self._current_item: Optional[Track] = None
|
||||||
|
|
@ -332,3 +333,8 @@ class Queue(Iterable[Track]):
|
||||||
def shuffle(self):
|
def shuffle(self):
|
||||||
"""Shuffles the queue."""
|
"""Shuffles the queue."""
|
||||||
return random.shuffle(self._queue)
|
return random.shuffle(self._queue)
|
||||||
|
|
||||||
|
def clear_track_filters(self):
|
||||||
|
"""Clears all filters applied to tracks"""
|
||||||
|
for track in self._queue:
|
||||||
|
track.filters = None
|
||||||
Loading…
Reference in New Issue