trimmed down music.py
This commit is contained in:
1 parent
f88fd7989a
commit
c2133705fe
36 files changed
+1010
-4
No files matched your search
@@ -0,0 +1 @@
|
||||
# shared package
|
||||
@@ -0,0 +1,23 @@
|
||||
# Colour palette
|
||||
C_MAIN = 0x8BE9FD # cyan – now playing
|
||||
C_QUEUE = 0xBD93F9 # purple – queue
|
||||
C_OK = 0x50FA7B # green – success
|
||||
C_WARN = 0xFFB86C # orange – warnings / loop
|
||||
C_ERR = 0xFF5555 # red – errors
|
||||
C_HIST = 0x6272A4 # muted – history
|
||||
C_RADIO = 0xFF79C6 # pink – radio
|
||||
|
||||
# Loop modes
|
||||
LOOP_OFF = 0
|
||||
LOOP_TRACK = 1
|
||||
LOOP_QUEUE = 2
|
||||
|
||||
LOOP_LABEL = {
|
||||
LOOP_OFF: "Off",
|
||||
LOOP_TRACK: "🔂 Track",
|
||||
LOOP_QUEUE: "🔁 Queue",
|
||||
}
|
||||
|
||||
# Playback modes
|
||||
MODE_MUSIC = "music"
|
||||
MODE_RADIO = "radio"
|
||||
@@ -0,0 +1,18 @@
|
||||
import wavelink
|
||||
from collections import deque
|
||||
from .constants import LOOP_OFF
|
||||
|
||||
|
||||
class GuildState:
|
||||
def __init__(self):
|
||||
self.queue: deque = deque()
|
||||
self.history: list = [] # last 10 tracks
|
||||
self.loop: int = LOOP_OFF
|
||||
self.autoplay: bool = False
|
||||
self.current: wavelink.Playable | None = None
|
||||
self.mode: str | None = None
|
||||
|
||||
def push_history(self, track: wavelink.Playable):
|
||||
self.history.insert(0, track)
|
||||
if len(self.history) > 10:
|
||||
self.history.pop()
|
||||
@@ -0,0 +1,33 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from .constants import C_ERR
|
||||
|
||||
|
||||
def fmt_duration(ms: int) -> str:
|
||||
s = ms // 1000
|
||||
m, s = divmod(s, 60)
|
||||
h, m = divmod(m, 60)
|
||||
return f"{h}:{m:02}:{s:02}" if h else f"{m}:{s:02}"
|
||||
|
||||
|
||||
def progress_bar(position_ms: int, duration_ms: int, width: int = 14) -> str:
|
||||
if duration_ms == 0:
|
||||
return "▬" * width
|
||||
pct = min(position_ms / duration_ms, 1.0)
|
||||
filled = int(pct * width)
|
||||
return "▬" * filled + "🔘" + "▬" * (width - filled)
|
||||
|
||||
|
||||
def is_dj():
|
||||
"""Soft DJ check — allows anyone to use info/play, restricts control commands."""
|
||||
async def predicate(ctx: commands.Context):
|
||||
if any(r.name.lower() == "dj" for r in ctx.author.roles):
|
||||
return True
|
||||
await ctx.reply(
|
||||
embed=discord.Embed(
|
||||
description="🎧 You need the **DJ** role to use this command.",
|
||||
color=C_ERR,
|
||||
)
|
||||
)
|
||||
return False
|
||||
return commands.check(predicate)
|
||||
Reference in new issue
Block a user