from discord.ext import commands import discord class Skip(commands.Cog): def __init__(self, bot): self.bot = bot self.queues = {} def get_queue(self, guild_id): return self.queues.setdefault(guild_id, []) def play_next(self, ctx, vc, guild_id): queue = self.get_queue(guild_id) if queue: _, _, file_path = queue[0] def after_playing(error=None): if queue: queue.pop(0) if queue: _, _, next_file = queue[0] if not vc.is_playing(): vc.play(discord.FFmpegPCMAudio(next_file), after=after_playing) if not vc.is_playing(): vc.play(discord.FFmpegPCMAudio(file_path), after=after_playing) @commands.slash_command(name="pomiƄ", description="przeskocz do nastepnej melodyji") async def pomin(self, ctx): guild_id = ctx.guild.id vc = ctx.voice_client if vc and vc.is_playing(): queue = self.get_queue(guild_id) if queue: queue.pop(0) if queue: vc.stop() self.play_next(ctx, vc, guild_id) await ctx.respond("przeskoczono do nastepnej melodyji") else: await ctx.respond("koleyjka jest pustawa") await vc.disconnect() else: await ctx.respond("nic nie gra") else: await ctx.respond("nic nie gra") def setup(bot): bot.add_cog(Skip(bot))