aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/skip.py
diff options
context:
space:
mode:
authorSamlonDev <stankiewiczgracjan2019@gmail.com>2025-05-20 05:45:23 +0200
committerSamlonDev <stankiewiczgracjan2019@gmail.com>2025-05-20 05:45:23 +0200
commitfcc3635b9f24051ae07ed597632597e20372c889 (patch)
tree20a29a1a784f218b3623ff03ceb8084839ff606a /cogs/music/skip.py
downloadsenator-sperma-fcc3635b9f24051ae07ed597632597e20372c889.tar.gz
senator-sperma-fcc3635b9f24051ae07ed597632597e20372c889.zip
initial push
Diffstat (limited to 'cogs/music/skip.py')
-rw-r--r--cogs/music/skip.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/cogs/music/skip.py b/cogs/music/skip.py
new file mode 100644
index 0000000..f48218b
--- /dev/null
+++ b/cogs/music/skip.py
@@ -0,0 +1,47 @@
1from discord.ext import commands
2import discord
3
4class Skip(commands.Cog):
5 def __init__(self, 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
26 @commands.slash_command(name="pomiƄ", description="przeskocz do nastepnej melodyji")
27 async def pomin(self, ctx):
28 guild_id = ctx.guild.id
29 vc = ctx.voice_client
30 if vc and vc.is_playing():
31 queue = self.get_queue(guild_id)
32 if queue:
33 queue.pop(0)
34 if queue:
35 vc.stop()
36 self.play_next(ctx, vc, guild_id)
37 await ctx.respond("przeskoczono do nastepnej melodyji")
38 else:
39 await ctx.respond("koleyjka jest pustawa")
40 await vc.disconnect()
41 else:
42 await ctx.respond("nic nie gra")
43 else:
44 await ctx.respond("nic nie gra")
45
46def setup(bot):
47 bot.add_cog(Skip(bot)) \ No newline at end of file