aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/loop.py
blob: 77f87b7dabab629b9c672d51397be677b57ffe09 (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
from discord.ext import commands
import logging

logger = logging.getLogger(__name__)


class Loop(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.looping = {}

    def is_looping(self, guild_id):
        return self.looping.get(guild_id, False)

    def set_looping(self, guild_id, value):
        self.looping[guild_id] = value

    @commands.slash_command(name="loop", description="włącz/wyłącz loopowanie dla bieżącej melodyji")
    async def loop(self, ctx):
        guild_id = ctx.guild.id
        looping = not self.is_looping(guild_id)
        self.set_looping(guild_id, looping)
        await ctx.respond(f"looping jest teraz {'włączony' if looping else 'wyłączony'}.")
        logger.info(f"Looping has been {'enabled' if looping else 'disabled'} for guild {guild_id}")


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