Exemple #1
0
    async def champion(self,
                       ctx: commands.Context,
                       champion_name: ChampionNameConverter(),
                       game_id: int = None):
        with session_scope() as session:
            if not game_id:
                game, participant = get_last_game(player_id=ctx.author.id,
                                                  server_id=ctx.guild.id,
                                                  session=session)
            else:
                game, participant = (session.query(
                    Game, GameParticipant).select_from(Game).join(
                        GameParticipant).filter(Game.id == game_id).filter(
                            GameParticipant.player_id == ctx.author.id)
                                     ).one_or_none()

            # We write down the champion
            participant.champion_id = champion_name

            game_id = game.id

        await ctx.send(
            f"Champion for game {game_id} was set to "
            f"{lol_id_tools.get_name(champion_name, object_type='champion')} for {ctx.author.display_name}"
        )
Exemple #2
0
    async def champion(
        self, ctx: commands.Context, champion_name: ChampionNameConverter(), game_id: int = None
    ):
        """
        Saves the champion you used in your last game

        Older games can be filled with !champion champion_name game_id
        You can find the ID of the games you played with !history

        Example:
            !champion riven
            !champion riven 1
        """

        with session_scope() as session:
            if not game_id:
                game, participant = get_last_game(
                    player_id=ctx.author.id, server_id=ctx.guild.id, session=session
                )
            else:
                game, participant = (
                    session.query(Game, GameParticipant)
                    .select_from(Game)
                    .join(GameParticipant)
                    .filter(Game.id == game_id)
                    .filter(GameParticipant.player_id == ctx.author.id)
                ).one_or_none()

            # We write down the champion
            participant.champion_id = champion_name

            game_id = game.id

        await ctx.send(
            f"Champion for game {game_id} was set to "
            f"{lol_id_tools.get_name(champion_name, object_type='champion')} for {ctx.author.display_name}"
        )
Exemple #3
0
    async def emoji(self, ctx: commands.Context, champion_id: ChampionNameConverter()):
        emoji_text = get_champion_emoji(champion_id, self.bot)

        await ctx.send(f"{champion_id} - {emoji_text}")