Exemplo n.º 1
0
    def __send_present(self,
                       invoking_user: discord.Member,
                       recipient: discord.Member,
                       server: Server,
                       present_name: str,
                       please=False):
        """One user sends a present to another.

        Args:
            invoking_user (discord.Member): Who sent the gift.
            recipient (discord.Member): Who the gift is for.
            server (Server): The parent Server of the present.
            present_name (str): The name of the gift.
            please (bool, optional): The magic word. Defaults to False.
        """
        recipient = self.bot.db.get_or_create(User, id=recipient.id)

        present = Present(name=present_name,
                          owner=recipient,
                          gifter=invoking_user,
                          server=server,
                          please=please)

        recipient.increment_owned_presents()
        invoking_user.increment_gifted_presents()

        self.bot.db.commit()
Exemplo n.º 2
0
    def __give_present(self,
                       invoking_user: discord.Member,
                       server: Server,
                       present_name: str,
                       *,
                       please=False) -> bool:
        """Give a present to a user who asked for one, then try to steal it.

        Args:
            invoking_user (discord.Member): Who asked for the present?
            server (Server): The parent Server of the present.
            present_name (str): The name of the present.
            please (bool, optional): Did they say please? Defaults to False.

        Returns:
            bool: Whether the Grinch stole their presents.
        """
        present = Present(name=present_name,
                          owner=invoking_user,
                          server=server,
                          please=please)

        invoking_user.increment_owned_presents()

        result = invoking_user.try_steal_presents()

        self.bot.db.commit()
        return result