Skip to content

Commit

Permalink
fix(player): set blank filter if no filters enabled (#51)
Browse files Browse the repository at this point in the history
* fix(player): set blank filter if no filters enabled

* fix(player): do not try to apply filters again
  • Loading branch information
ooliver1 committed Feb 17, 2023
1 parent fb0c844 commit 8ccf60e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mafic/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ async def _update_filters(self, *, fast_apply: bool) -> None:
Whether to seek to the current position after updating the filters.
"""

await self.update(filter=reduce(or_, self._filters.values()))
await self.update(
filter=reduce(or_, self._filters.values()) if self._filters else Filter()
)

if fast_apply:
await self.seek(self.position)
Expand Down
40 changes: 39 additions & 1 deletion test_bot/bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
from nextcord import Intents, Interaction
from nextcord.abc import Connectable

from mafic import Group, NodePool, Player, Playlist, Region, Track, TrackEndEvent
from mafic import (
EQBand,
Equalizer,
Filter,
Group,
NodePool,
Player,
Playlist,
Region,
Track,
TrackEndEvent,
)

getLogger("mafic").setLevel(DEBUG)

Expand Down Expand Up @@ -247,4 +258,31 @@ async def stats(inter: Interaction):
)


@bot.slash_command()
async def boost(inter: Interaction):
if not inter.guild.voice_client:
return await inter.send("I am not in a voice channel.")

player: MyPlayer = inter.guild.voice_client

bassboost_equalizer = Equalizer([EQBand(idx, 0.30) for idx in range(0, 15)])

bassboost_filter = Filter(bassboost_equalizer)
await player.add_filter(bassboost_filter, label="boost")

await inter.send("Boost enabled.")


@bot.slash_command()
async def unboost(inter: Interaction):
if not inter.guild.voice_client:
return await inter.send("I am not in a voice channel.")

player: MyPlayer = inter.guild.voice_client

await player.remove_filter("boost")

await inter.send("Boost disabled.")


bot.run(getenv("TOKEN"))

0 comments on commit 8ccf60e

Please sign in to comment.