added effects to songs!

This commit is contained in:
2025-11-27 15:13:59 +00:00
parent c7e033acb6
commit 9660246d6a
3 changed files with 535 additions and 82 deletions

View File

@@ -175,4 +175,171 @@ class music(commands.Cog):
await queue.pop(server.id, True)
# Safe to ignore error for now
ctx.voice_client.stop()
ctx.voice_client.stop()
@commands.command(
help="Toggle loop mode: off -> song -> queue -> off",
aliases=['l', 'repeat'])
async def loop(self, ctx: Context, mode: str = None):
"""Toggle between loop modes or set a specific mode"""
server = ctx.guild
if server is None:
raise commands.CommandError("Command must be issued in a server")
current_mode = await queue.get_loop_mode(server.id)
# If no mode specified, cycle through modes
if mode is None:
if current_mode == 'off':
new_mode = 'song'
elif current_mode == 'song':
new_mode = 'queue'
else:
new_mode = 'off'
else:
# Set specific mode
mode = mode.lower()
if mode not in ['off', 'song', 'queue']:
raise commands.CommandError("Loop mode must be: off, song, or queue")
new_mode = mode
await queue.set_loop_mode(server.id, new_mode)
# Response messages
emojis = {'off': '⏹️', 'song': '🔂', 'queue': '🔁'}
messages = {
'off': 'Loop disabled',
'song': 'Looping current song 🔂',
'queue': 'Looping entire queue 🔁'
}
await ctx.send(f"{emojis[new_mode]} {messages[new_mode]}")
@commands.command(
help="Shuffle the queue randomly",
aliases=['mix', 'randomize'])
async def shuffle(self, ctx: Context):
"""Shuffle all songs in the queue"""
server = ctx.guild
if server is None:
raise commands.CommandError("Command must be issued in a server")
success = await queue.shuffle_queue(server.id)
if not success:
await ctx.send("🚫 Not enough songs in the queue to shuffle!")
else:
await ctx.message.add_reaction('🔀')
await ctx.send("🔀 Queue shuffled!")
@commands.command(
help="Set playback volume (0-200%)",
aliases=['vol', 'v'])
async def volume(self, ctx: Context, vol: str = None):
"""Set or display the current volume"""
server = ctx.guild
if server is None:
raise commands.CommandError("Command must be issued in a server")
if vol is None:
# Display current volume
current_vol = await queue.get_volume(server.id)
await ctx.send(f"🔊 Current volume: {current_vol}%")
return
# Set volume
if not vol.isdigit():
raise commands.CommandError("Volume must be a number (0-200)")
vol = int(vol)
if vol < 0 or vol > 200:
raise commands.CommandError("Volume must be between 0 and 200")
new_vol = await queue.set_volume(server.id, vol)
# Update the current playing song's volume if something is playing
if ctx.voice_client and ctx.voice_client.source:
ctx.voice_client.source.volume = new_vol / 100.0
# Pick an emoji based on volume
if new_vol == 0:
emoji = '🔇'
elif new_vol < 50:
emoji = '🔉'
elif new_vol < 100:
emoji = '🔊'
else:
emoji = '📢'
await ctx.send(f"{emoji} Volume set to {new_vol}%")
@commands.command(
help="Apply audio effects to playback",
aliases=['fx', 'filter'])
async def effect(self, ctx: Context, effect_name: str = None):
"""Apply or list audio effects"""
server = ctx.guild
if server is None:
raise commands.CommandError("Command must be issued in a server")
# If no effect specified, show current effect and list options
if effect_name is None:
current = await queue.get_effect(server.id)
emoji = queue.get_effect_emoji(current)
desc = queue.get_effect_description(current)
effects_list = '\n'.join([
f"`{e}` - {queue.get_effect_description(e)}"
for e in queue.list_all_effects()[:7] # Show first 7
])
more_effects = '\n'.join([
f"`{e}` - {queue.get_effect_description(e)}"
for e in queue.list_all_effects()[7:] # Show rest
])
await ctx.send(
f"{emoji} **Current effect:** {current} - {desc}\n\n"
f"**Available effects:**\n{effects_list}\n\n"
f"**More effects:**\n{more_effects}\n\n"
f"Use `=effect <name>` to apply an effect!"
)
return
# Set effect
effect_name = effect_name.lower()
if effect_name not in queue.list_all_effects():
raise commands.CommandError(
f"Unknown effect! Use `=effect` to see available effects."
)
await queue.set_effect(server.id, effect_name)
emoji = queue.get_effect_emoji(effect_name)
desc = queue.get_effect_description(effect_name)
# Special warning for earrape
if effect_name == 'earrape':
await ctx.send(
f"⚠️ **EARRAPE MODE ACTIVATED** ⚠️\n"
f"RIP your eardrums. Effect will apply to next song.\n"
f"Use `=effect none` to disable."
)
else:
await ctx.send(
f"{emoji} Effect set to **{effect_name}**\n"
f"{desc}\n"
f"Effect will apply to next song!"
)
# If something is currently playing, notify about skip
if ctx.voice_client and ctx.voice_client.is_playing():
await ctx.send("💡 Tip: Use `=skip` to apply effect to current song immediately!")