aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/skip.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/music/skip.py')
-rw-r--r--cogs/music/skip.py84
1 files changed, 49 insertions, 35 deletions
diff --git a/cogs/music/skip.py b/cogs/music/skip.py
index f48218b..67c391e 100644
--- a/cogs/music/skip.py
+++ b/cogs/music/skip.py
@@ -4,44 +4,58 @@ import discord
4class Skip(commands.Cog): 4class Skip(commands.Cog):
5 def __init__(self, bot): 5 def __init__(self, bot):
6 self.bot = bot 6 self.bot = bot
7 self.queues = {}
8
9 def get_queue(self, guild_id):
10 return self.queues.setdefault(guild_id, [])
11
12 def play_next(self, ctx, vc, guild_id):
13 queue = self.get_queue(guild_id)
14 if queue:
15 _, _, file_path = queue[0]
16 def after_playing(error=None):
17 if queue:
18 queue.pop(0)
19 if queue:
20 _, _, next_file = queue[0]
21 if not vc.is_playing():
22 vc.play(discord.FFmpegPCMAudio(next_file), after=after_playing)
23 if not vc.is_playing():
24 vc.play(discord.FFmpegPCMAudio(file_path), after=after_playing)
25 7
26 @commands.slash_command(name="pomiń", description="przeskocz do nastepnej melodyji") 8 @commands.slash_command(name="pomiń", description="przeskocz do nastepnej melodyji")
27 async def pomin(self, ctx): 9 async def pomin(self, ctx):
28 guild_id = ctx.guild.id 10 """Skip the current song and play the next one in the queue."""
29 vc = ctx.voice_client 11 vc = ctx.voice_client
30 if vc and vc.is_playing(): 12
31 queue = self.get_queue(guild_id) 13 if not vc or not vc.is_connected():
32 if queue: 14 await ctx.respond("Nie jestem połączony z kanałem głosowym.")
33 queue.pop(0) 15 return
34 if queue: 16
35 vc.stop() 17 if not vc.is_playing() and not vc.is_paused():
36 self.play_next(ctx, vc, guild_id) 18 await ctx.respond("Nic nie jest teraz odtwarzane.")
37 await ctx.respond("przeskoczono do nastepnej melodyji") 19 return
38 else: 20
39 await ctx.respond("koleyjka jest pustawa") 21 # Get the play cog
40 await vc.disconnect() 22 play_cog = self.bot.get_cog('Play')
41 else: 23 if not play_cog:
42 await ctx.respond("nic nie gra") 24 await ctx.respond("Błąd: Nie można znaleźć modułu odtwarzania.")
43 else: 25 return
44 await ctx.respond("nic nie gra") 26
27 queue = play_cog.get_queue(ctx.guild.id)
28
29 if not queue:
30 await ctx.respond("Kolejka jest pusta.")
31 return
32
33 # Stop the current song (this will trigger play_next in the after callback)
34 vc.stop()
35 await ctx.respond("Pominięto aktualną piosenkę.")
36
37 @commands.slash_command(name="kolejka", description="pokaż aktualną kolejkę")
38 async def queue_list(self, ctx):
39 """Show the current queue."""
40 play_cog = self.bot.get_cog('Play')
41 if not play_cog:
42 await ctx.respond("Błąd: Nie można znaleźć modułu odtwarzania.")
43 return
44
45 queue = play_cog.get_queue(ctx.guild.id)
46
47 if not queue:
48 await ctx.respond("Kolejka jest pusta.")
49 return
50
51 queue_list = []
52 for i, (title, _) in enumerate(queue[:10], 1): # Show up to 10 songs
53 queue_list.append(f"{i}. {title}")
54
55 if len(queue) > 10:
56 queue_list.append(f"...i {len(queue) - 10} więcej")
57
58 await ctx.respond("\n".join(["**Kolejka:**"] + queue_list))
45 59
46def setup(bot): 60def setup(bot):
47 bot.add_cog(Skip(bot)) \ No newline at end of file 61 bot.add_cog(Skip(bot)) \ No newline at end of file