Beispiel #1
0
async def run(message):
    if not await utils.check_voice_channel(message):
        await message.reply("You have to be in a voice channel")
        return

    if not utils.check_for_existing_queue(message):
        await message.reply("Nothing is playing")
        return

    queue = utils.get_queue(message.guild.id)

    queue.loop += 1

    if queue.loop > 2:
        queue.loop = 0

    mode = ""
    if queue.loop == 0:
        mode = "None"
    elif queue.loop == 1:
        mode = "Queue"
    elif queue.loop == 2:
        mode = "Song"
    await message.channel.send(embed=Embed(
        description="Now looping {0}".format(mode),
        colour=Color.from_rgb(141, 41, 255)),
                               delete_after=5)
Beispiel #2
0
async def run(message):
    queue = utils.get_queue(message.guild.id)
    output = ""

    if not queue:
        await message.channel.send("No queue found on this server")
        return
    page = queue.queue_page
    available_pages = len(queue.tracks) / 15
    if page < 0:
        page = 0
    elif page > available_pages:
        page = math.ceil(available_pages)
    counter = (page * 15)+1

    if len(queue.tracks) >= 1:
        for i in get_tracks_from_to(1+(15*page), 14+(15*page), queue):
            if queue.now_playing_index + 1 == counter:
                output += "🔴 "
            output = output + "{0}. {1}\n".format(counter, i.title)
            counter += 1
    if output:
        if not queue.queue_message:
            queue.queue_message = await message.channel.send("Page {0}```{1}```".format(page+1, output))
            if available_pages > 1:
                await queue.queue_message.add_reaction("⬆")
                await queue.queue_message.add_reaction("⬇")
                await queue.queue_message.add_reaction("❌")
        else:
            await queue.queue_message.edit(content="Page {0}```{1}```".format(page+1, output))
        await queue.queue_message.add_reaction("❌")
    else:
        await message.channel.send(embed=Embed(description="Queue is empty!", colour=Color.from_rgb(237, 19, 19)))
Beispiel #3
0
async def run(message, args):
    queue = utils.get_queue(message.guild.id)
    if not queue:
        await message.channel.send("No queue found on this server")
        return
    if not args:
        await message.channel.reply("You have to pass a song number in queue.")
        return

    length = len(queue.tracks)

    selected = int(args[0])
    selected_second = int(args[1])

    if not selected <= length and selected > 0:
        await message.reply("Well, id is invalid")
        return
    if not selected_second <= length and selected_second > 0:
        await message.reply("Well, second id is invalid")
        return
    if queue.tracks[selected - 1] and queue.tracks[selected_second - 1]:
        track = queue.tracks.pop(selected - 1)
        queue.tracks.insert(selected_second - 1, track)
    else:
        await message.channel.reply("This id is invalid")
Beispiel #4
0
async def run(message):
    if not await utils.check_voice_channel(message):
        await message.channel.send("You have to be in a voice channel")
        return
    if not utils.get_queue(message.guild.id):
        await message.channel.send("No queue found on this server")
        return
    utils.resume(message)
    await utils.skip(message)
Beispiel #5
0
async def on_voice_state_update(member, before, after):
    if member.id == client.user.id:
        if not after.channel:
            queue = utils.get_queue(before.channel.guild.id)
            if not queue:
                return
            await utils.destroy_queue(before.channel.guild.id)
            await queue.first_message.channel.send(
                embed=Embed(description="I got disconnected from the channel.",
                            colour=Color.from_rgb(237, 19, 19)))
Beispiel #6
0
async def run(message, args):
    # Shows all available filters if no queue is present
    if not utils.check_for_existing_queue(message):
        msg = ""
        for key in filters.keys():
            msg += key + "\n"
        embed = discord.Embed(title="List of available filters",
                              description=msg,
                              colour=discord.Color.from_rgb(35, 219, 201))
        await message.channel.send(embed=embed)
        return
    elif not args:
        queue = utils.get_queue(message.guild.id)
        msg = ""
        for val in queue.filters:
            for name in filters.keys():
                if filters.get(name) == val:
                    msg += name + "\n"
                    break
        embed = discord.Embed(title="List of active filters",
                              description=msg,
                              colour=discord.Color.from_rgb(35, 219, 201),
                              delete_after=20)
        await message.channel.send(embed=embed)
        return
    queue = utils.get_queue(message.guild.id)

    for requested in args:
        found = filters.get(requested.lower())
        deleted = False
        for i in range(len(queue.filters)):
            if queue.filters[i] == found:
                queue.filters.pop(i)
                deleted = True
                break

        if found and not deleted:
            queue.filters.append(found)
        elif not found:
            await message.channel.send(
                "Couldn't match any filter with {0}".format(requested))
    print("Updating...")
    await utils.filters_updated(message)
Beispiel #7
0
async def run(message):
    if not await utils.check_voice_channel(message):
        await message.reply("You have to be in a voice channel")
        return
    if not utils.check_for_existing_queue(message):
        await message.reply("No queue found on this server")
        return

    queue = utils.get_queue(message.guild.id)

    queue.now_playing_index -= 2
    queue.voice_connection.stop()
Beispiel #8
0
async def handle(reaction, member):
    queue = utils.get_queue(reaction.message.guild.id)
    if not queue or not queue.voice_connection:
        return
    if member.voice.channel.id != queue.voice_connection.channel.id or member.id == queue.voice_connection.user.id:
        return
    print(
        f"REACTION EMOJI: {reaction.emoji} GUILD: {reaction.message.guild.name}"
    )
    if queue.now_playing.id == reaction.message.id:
        if reaction.emoji == "⏮":
            await back.run(reaction.message)
        elif reaction.emoji == "⏯":
            if not utils.get_queue(
                    reaction.message.guild.id).voice_connection.is_paused():
                utils.pause(reaction.message)
            else:
                utils.resume(reaction.message)
        elif reaction.emoji == "⏭":
            await skip.run(reaction.message)
        elif reaction.emoji == "🔃":
            await loop.run(reaction.message)
        elif reaction.emoji == "🔀":
            await shuffle.run(reaction.message)
        elif reaction.emoji == "⏹":
            await utils.destroy_queue(reaction.message.guild.id)
            return
    elif queue.queue_message.id == reaction.message.id:
        # Queue User reacted to our message
        if reaction.emoji == "⬇":
            queue.queue_page += 1
            await queue_cmd.run(queue.first_message)
        elif reaction.emoji == "⬆":
            queue.queue_page -= 1
            await queue_cmd.run(queue.first_message)
        elif reaction.emoji == "❌":
            await queue.queue_message.delete()
            queue.queue_message = None
            return
Beispiel #9
0
async def run(message):
    queue = utils.get_queue(message.guild.id)

    if not await utils.check_voice_channel(message):
        await message.channel.send("You have to be in a voice channel")
        return

    if not queue:
        await message.channel.send("Queue for that server doesn't exist")
        return

    queue.tracks.clear()

    queue.voice_connection.stop()
Beispiel #10
0
async def run(message, args):
    if not await utils.check_voice_channel(message):
        await message.channel.send("You have to be in a voice channel")
        return

    queue = utils.get_queue(message.guild.id)
    if not args or not args[0]:
        return
    args[0] = int(args[0])
    if args[0] > len(queue.tracks) or args[0] < 1:
        return

    queue.now_playing_index = args[0] - 2
    queue.voice_connection.stop()
Beispiel #11
0
async def run(message):
    if not await utils.check_voice_channel(message):
        await message.channel.send("You have to be in a voice channel")
        return

    if not utils.check_for_existing_queue(message):
        await message.channel.send("Nothing is playing")
        return

    queue = utils.get_queue(message.guild.id)

    dont_touch = queue.tracks[:queue.now_playing_index+1]
    queue.tracks = queue.tracks[queue.now_playing_index+1:]
    shuffle(queue.tracks)
    queue.tracks = dont_touch + queue.tracks

    await message.channel.send("Shuffled 🔀")
Beispiel #12
0
async def run(message, args):
    queue = utils.get_queue(message.guild.id)
    if not queue:
        await message.channel.send("Not queue found for this server")
        return
    if not args:
        await message.channel.send("You have to pass a song number in queue.")
        return

    length = len(queue.tracks)

    selected = int(args[0])
    if not selected <= length and selected > 0:
        await message.channel.send("Well, id is invalid", delete_after=10)
        return
    if queue.tracks[selected - 1]:
        queue.tracks.pop(selected - 1)
    else:
        await message.channel.channel.send("This id is invalid",
                                           delete_after=10)
Beispiel #13
0
 def defer(self, fn, *args, **kwargs):
     q = utils.get_queue()
     job = q.enqueue(fn, *args, **kwargs)
     return BaseHandler.deferred_result(job)