コード例 #1
0
    async def queue(
        self,
        ctx: commands.Context,
        role: RoleConverter(),
        duo: discord.Member = None,
        duo_role: RoleConverter() = None,
    ):
        """
        Adds you to the current channel’s queue for the given role

        To duo queue, add @player role at the end (cf examples)

        Roles are TOP, JGL, MID, BOT/ADC, and SUP

        Example:
            !queue SUP
            !queue bot
            !queue adc
            !queue adc @CoreJJ support
        """
        # Checking if the last game of this player got cancelled
        #   If so, we put them in the queue in front of other players
        jump_ahead = False

        # pop with two arguments returns the second one if the key was not found
        if cancel_timestamp := self.players_whose_last_game_got_cancelled.pop(
                ctx.author.id, None):

            if datetime.now() - cancel_timestamp < timedelta(hours=1):
                jump_ahead = True
コード例 #2
0
    async def queue(
            self,
            ctx: commands.Context,
            role: RoleConverter(),
    ):
        """
        Adds you to the current channel’s queue for the given role

        Roles are TOP, JGL, MID, BOT/ADC, and SUP

        Example:
            !queue SUP
            !queue support
            !queue bot
            !queue adc
        """

        # Queuing the player
        game_queue.add_player(
            player_id=ctx.author.id,
            name=ctx.author.display_name,
            role=role,
            channel_id=ctx.channel.id,
            server_id=ctx.guild.id,
        )

        await self.run_matchmaking_logic(ctx=ctx)

        await queue_channel_handler.update_queue_channels(
            bot=self.bot, server_id=ctx.guild.id)
コード例 #3
0
ファイル: queue_cog.py プロジェクト: ViniFlores/inhouse_bot
    async def queue(
        self,
        ctx: commands.Context,
        role: RoleConverter(),
        duo: discord.Member = None,
        duo_role: RoleConverter() = None,
    ):
        # Checking if the last game of this player got cancelled
        #   If so, we put them in the queue in front of other players
        jump_ahead = False

        # pop with two arguments returns the second one if the key was not found
        if cancel_timestamp := self.players_whose_last_game_got_cancelled.pop(ctx.author.id, None):

            if datetime.now() - cancel_timestamp < timedelta(hours=1):
                jump_ahead = True
コード例 #4
0
ファイル: stats_cog.py プロジェクト: TS96/inhouse_bot
    async def ranking(self,
                      ctx: commands.Context,
                      role: RoleConverter() = None):
        """
        Displays the top players on the server

        A role can be supplied to only display the ranking for this role

        Example:
            !ranking
            !ranking mid
        """
        ratings = ranking_channel_handler.get_server_ratings(ctx.guild.id,
                                                             role=role)

        if not ratings:
            await ctx.send("No games played yet")
            return

        pages = menus.MenuPages(
            source=RankingPagesSource(
                ratings,
                embed_name_suffix=
                f"on {ctx.guild.name}{f' - {get_role_emoji(role)}' if role else ''}",
            ),
            clear_reactions_after=True,
        )
        await pages.start(ctx)
コード例 #5
0
ファイル: stats_cog.py プロジェクト: raducutv/inhouse_bot
    async def ranking(self,
                      ctx: commands.Context,
                      role: RoleConverter() = None):
        """
        Displays the top players on the server

        A role can be supplied to only display the ranking for this role

        Example:
            !ranking
            !ranking mid
        """
        with session_scope() as session:
            session.expire_on_commit = False

            ratings = (
                session.query(
                    Player,
                    PlayerRating.player_server_id,
                    PlayerRating.mmr,
                    PlayerRating.role,
                    func.count().label("count"),
                    (sqlalchemy.func.sum(
                        (Game.winner == GameParticipant.side).cast(
                            sqlalchemy.Integer))
                     ).label("wins"),  # A bit verbose for sure
                ).select_from(Player).join(PlayerRating).join(GameParticipant).
                join(Game).filter(Player.server_id == ctx.guild.id).group_by(
                    Player, PlayerRating).order_by(PlayerRating.mmr.desc()))

            if role:
                ratings = ratings.filter(PlayerRating.role == role)

            ratings = ratings.limit(100).all()

        if not ratings:
            await ctx.send("No games played yet")
            return

        pages = menus.MenuPages(
            source=RankingPagesSource(
                ratings,
                self.bot,
                embed_name_suffix=
                f"on {ctx.guild.name}{f' - {get_role_emoji(role)}' if role else ''}",
            ),
            clear_reactions_after=True,
        )
        await pages.start(ctx)
コード例 #6
0
    async def ranking(self,
                      ctx: commands.Context,
                      role: RoleConverter() = None):
        ratings = ranking_channel_handler.get_server_ratings(ctx.guild.id,
                                                             role=role)

        if not ratings:
            await ctx.send("No games played yet")
            return

        pages = menus.MenuPages(
            source=RankingPagesSource(
                ratings,
                embed_name_suffix=
                f"on {ctx.guild.name}{f' - {get_role_emoji(role)}' if role else ''}",
            ),
            clear_reactions_after=True,
        )
        await pages.start(ctx)