feat: Add moderation features and voting system.

This commit is contained in:
Lemon4ksan
2025-01-19 14:29:13 +03:00
parent b9ea63b4d5
commit 025046a8cb
9 changed files with 328 additions and 115 deletions

View File

@@ -77,7 +77,8 @@ class BaseGuildsDatabase:
current_player=None,
is_stopped=True,
allow_explicit=True,
allow_menu=True,
always_allow_menu=False,
disable_vote=False,
shuffle=False,
repeat=False
))

View File

@@ -142,6 +142,23 @@ class VoiceGuildsDatabase(BaseGuildsDatabase):
return track
def set_current_track(self, gid: int, track: Track | dict[str, Any]) -> None:
"""Set current track.
Args:
gid (int): Guild id.
track (Track | dict[str, Any]): Track or dictionary covertable to yandex_music.Track.
"""
if isinstance(track, Track):
track = track.to_dict()
self.update(gid, {'current_track': track})
self.update(gid, {'current_track': track})
def get_current_player(self, gid: int) -> int | None:
"""Get current player.
Args:
gid (int): Guild id.
Returns: int | None: Player message id or None if not present.
"""
guild = self.get_guild(gid)
return guild['current_player']

View File

@@ -7,7 +7,8 @@ class Guild(TypedDict, total=False):
current_player: int | None
is_stopped: bool
allow_explicit: bool
allow_menu: bool
always_allow_menu: bool
disable_vote: bool
shuffle: bool
repeat: bool
@@ -19,6 +20,7 @@ class ExplicitGuild(TypedDict):
current_player: int | None
is_stopped: bool # Prevents the `after` callback of play_track
allow_explicit: bool
allow_menu: bool # /toggle menu is only available if there's only one user in the voice chat.
always_allow_menu: bool
disable_vote: bool
shuffle: bool
repeat: bool