aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/skip.py
blob: b0023fe26d37203554c1738b6fe23b490f4fa869 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from discord.ext import commands


class Skip(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command(name="pomiń", description="przeskocz do nastepnej melodyji")
    async def pomin(self, ctx):
        """Skip the current song and play the next one in the queue."""
        vc = ctx.voice_client

        if not vc or not vc.is_connected():
            await ctx.respond("Nie jestem połączony z kanałem głosowym.")
            return

        if not vc.is_playing() and not vc.is_paused():
            await ctx.respond("Nic nie jest teraz odtwarzane.")
            return

        # Get the play cog
        play_cog = self.bot.get_cog('Play')
        if not play_cog:
            await ctx.respond("Błąd: Nie można znaleźć modułu odtwarzania.")
            return

        queue = play_cog.get_queue(ctx.guild.id)

        if not queue:
            await ctx.respond("Kolejka jest pusta.")
            return

        # Stop the current song (this will trigger play_next in the after callback)
        vc.stop()
        await ctx.respond("Pominięto aktualną piosenkę.")

    @commands.slash_command(name="kolejka", description="pokaż aktualną kolejkę")
    async def queue_list(self, ctx):
        """Show the current queue."""
        play_cog = self.bot.get_cog('Play')
        if not play_cog:
            await ctx.respond("Błąd: Nie można znaleźć modułu odtwarzania.")
            return

        queue = play_cog.get_queue(ctx.guild.id)

        if not queue:
            await ctx.respond("Kolejka jest pusta.")
            return

        queue_list = []
        for i, (title, _) in enumerate(queue[:10], 1):  # Show up to 10 songs
            queue_list.append(f"{i}. {title}")

        if len(queue) > 10:
            queue_list.append(f"...i {len(queue) - 10} więcej")

        await ctx.respond("\n".join(["**Kolejka:**"] + queue_list))


def setup(bot):
    bot.add_cog(Skip(bot))