fixed queue skip error, implemented more /commands.

This commit is contained in:
2025-11-27 20:24:51 +00:00
parent a36977b000
commit 7f8f77fb76
4 changed files with 420 additions and 26 deletions

View File

@@ -68,7 +68,7 @@ class music(commands.Cog):
await util.join_vc(ctx)
await ctx.message.add_reaction('👍')
@commands.command(
help="Leaves the voice chat if the bot is present",
aliases=['disconnect'])
@@ -80,7 +80,8 @@ class music(commands.Cog):
# HYBRID COMMAND - works as both =play and /play
@commands.hybrid_command(
name="play",
description="Queue a song to play")
description="Queue a song to play",
aliases=['p'])
@app_commands.describe(query="YouTube URL, Spotify link, or search query")
async def play(self, ctx: Context, *, query: str):
"""Queues a song into the bot"""
@@ -95,13 +96,13 @@ class music(commands.Cog):
await ctx.defer()
await util.join_vc(ctx)
# Different responses for slash vs prefix
if not ctx.interaction:
await ctx.message.add_reaction('👍')
msg = await ctx.send("Fetching song(s)...")
#TODO potentially save requests before getting stream link
# Grab video details such as title thumbnail duration
audio = await translate.main(query, self.sp)
@@ -187,7 +188,8 @@ class music(commands.Cog):
@commands.hybrid_command(
name="queue",
description="Display the current music queue")
description="Display the current music queue",
aliases=['q', 'songs'])
async def queue_cmd(self, ctx: Context):
"""Display the current music queue"""
server = ctx.guild
@@ -208,10 +210,11 @@ class music(commands.Cog):
# Display songs
await util.display_server_queue(ctx, songs, n)
@commands.hybrid_command(
name="skip",
description="Skip the current song")
description="Skip the current song",
aliases=['s'])
@app_commands.describe(count="Number of songs to skip (default: 1)")
async def skip(self, ctx: Context, count: int = 1):
"""Skips the current song that is playing"""
@@ -231,7 +234,7 @@ class music(commands.Cog):
# Check loop mode
loop_mode = await queue.get_loop_mode(server.id)
if loop_mode == 'song' and count == 1:
# When looping song and skipping once, just restart it
ctx.voice_client.stop()
@@ -240,18 +243,19 @@ class music(commands.Cog):
# Skip specified number of songs
for _ in range(count-1):
await queue.pop(server.id, True, skip_mode=True)
# Last song gets skip_mode=True to handle loop properly
if loop_mode != 'song':
await queue.pop(server.id, True, skip_mode=True)
ctx.voice_client.stop()
await ctx.send(f"⏭️ Skipped {count} song(s)")
@commands.hybrid_command(
name="loop",
description="Toggle loop mode")
description="Toggle loop mode",
aliases=['l', 'repeat'])
@app_commands.describe(mode="Loop mode: off, song, or queue")
@app_commands.choices(mode=[
app_commands.Choice(name="Off", value="off"),
@@ -318,7 +322,8 @@ class music(commands.Cog):
@commands.hybrid_command(
name="volume",
description="Set playback volume")
description="Set playback volume",
aliases=['vol', 'v'])
@app_commands.describe(level="Volume level (0-200%, default shows current)")
async def volume(self, ctx: Context, level: int = None):
"""Set or display the current volume"""
@@ -360,7 +365,8 @@ class music(commands.Cog):
@commands.hybrid_command(
name="effect",
description="Apply audio effects to playback")
description="Apply audio effects to playback",
aliases=['fx', 'filter'])
@app_commands.describe(effect_name="The audio effect to apply (leave empty to see list)")
async def effect(self, ctx: Context, effect_name: str = None):
"""Apply or list audio effects"""
@@ -375,16 +381,16 @@ class music(commands.Cog):
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)}"
f"`{e}` - {queue.get_effect_description(e)}"
for e in queue.list_all_effects()[:9] # Show first 9
])
more_effects = '\n'.join([
f"`{e}` - {queue.get_effect_description(e)}"
f"`{e}` - {queue.get_effect_description(e)}"
for e in queue.list_all_effects()[9:] # Show rest
])
await ctx.send(
f"{emoji} **Current effect:** {current} - {desc}\n\n"
f"**Available effects:**\n{effects_list}\n\n"
@@ -395,7 +401,7 @@ class music(commands.Cog):
# Set effect
effect_name = effect_name.lower()
if effect_name not in queue.list_all_effects():
await ctx.send(
f"❌ Unknown effect! Use `/effect` to see available effects.",
@@ -404,10 +410,10 @@ class music(commands.Cog):
return
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/deepfry
if effect_name in ['earrape', 'deepfry']:
await ctx.send(