Beispiel #1
0
    async def reset(self,
                    ctx: commands.Context,
                    member_or_channel: Union[discord.Member,
                                             discord.TextChannel] = None):
        """
        Resets the queue status for a channel or a player

        If no argument is given, resets the queue in the current channel
        """
        if not member_or_channel or type(
                member_or_channel) == discord.TextChannel:
            channel = ctx.channel if not member_or_channel else member_or_channel
            game_queue.reset_queue(channel.id)

            # TODO Find a way to cancel the ongoing ready-checks as they *will* bug out
            #   The current code organisation does not allow to do it easily, so maybe it’ll need some structure changes
            await ctx.send(f"Queue has been reset in {channel.name}")

        elif type(member_or_channel) == discord.Member:
            game_queue.remove_player(member_or_channel.id)
            await ctx.send(
                f"{member_or_channel.name} has been removed from all queues")

        await queue_channel_handler.update_queue_channels(
            bot=self.bot, server_id=ctx.guild.id)
Beispiel #2
0
    async def leave(
        self,
        ctx: commands.Context,
    ):
        game_queue.remove_player(player_id=ctx.author.id,
                                 channel_id=ctx.channel.id)

        await queue_channel_handler.update_queue_channels(
            bot=self.bot, server_id=ctx.guild.id)
def test_queue_remove():
    game_queue.reset_queue()

    game_queue.add_player(0, roles_list[0], 0, 0, name="0")

    assert len(GameQueue(0)) == 1

    # We queue our player 0 in channel 1, which he should be allowed to do
    game_queue.remove_player(0, 0)

    assert len(GameQueue(0)) == 0
Beispiel #4
0
    async def leave(
        self,
        ctx: commands.Context,
    ):
        """
        Removes you from the queue in the current channel

        Example:
            !leave
            !leave_queue
        """

        game_queue.remove_player(player_id=ctx.author.id,
                                 channel_id=ctx.channel.id)

        await queue_channel_handler.update_queue_channels(
            bot=self.bot, server_id=ctx.guild.id)
Beispiel #5
0
    async def reset(
        self, ctx: commands.Context, member_or_channel: Union[discord.Member, discord.TextChannel] = None
    ):
        """
        Resets the queue status for a channel or a player

        If no argument is given, resets the queue in the current channel
        """
        # TODO LOW PRIO RESEND THE QUEUE (but it’s a QueueCog function, so will need some code rearrangement)

        if not member_or_channel or type(member_or_channel) == discord.TextChannel:
            channel = ctx.channel if not member_or_channel else member_or_channel
            game_queue.reset_queue(channel.id)

            await ctx.send(f"Queue has been reset in {channel.name}")
            await queue_channel_handler.update_server_queues(bot=self.bot, server_id=ctx.guild.id)

        elif type(member_or_channel) == discord.Member:
            game_queue.remove_player(member_or_channel.id)
            await ctx.send(f"{member_or_channel.name} has been removed from all queues")
            await queue_channel_handler.update_server_queues(bot=self.bot, server_id=ctx.guild.id)
Beispiel #6
0
    async def reset(self,
                    ctx: commands.Context,
                    member_or_channel: Union[discord.Member,
                                             discord.TextChannel] = None):
        """
        Resets the queue status for a channel or a player

        If no argument is given, resets the queue in the current channel
        """
        if not member_or_channel or type(
                member_or_channel) == discord.TextChannel:
            channel = ctx.channel if not member_or_channel else member_or_channel
            game_queue.reset_queue(channel.id)

            await ctx.send(f"Queue has been reset in {channel.name}")

        elif type(member_or_channel) == discord.Member:
            game_queue.remove_player(member_or_channel.id)
            await ctx.send(
                f"{member_or_channel.name} has been removed from all queues")

        await queue_channel_handler.update_queue_channels(
            bot=self.bot, server_id=ctx.guild.id)