Esempio n. 1
0
    def __init__(self, client, **kwargs):
        super().__init__(kwargs.get("id"), client)

        #: The content of the message.
        self.content = kwargs.get("content", None)  # type: str

        #: The ID of the guild this message is in.
        self.guild_id = None

        #: The ID of the channel the message was sent in.
        self.channel_id = int(kwargs.get("channel_id", 0))  # type: int

        #: The :class:`~.Channel` this message was sent in.
        self.channel = None  # type: dt_channel.Channel

        #: The ID of the author.
        self.author_id = int(kwargs.get("author", {}).get("id", 0)) or None  # type: int

        #: The author of this message. Can be one of: :class:`.Member`, :class:`.Webhook`,
        #: :class:`.User`.
        self.author = None  # type: typing.Union[dt_member.Member, dt_webhook.Webhook]

        type_ = kwargs.get("type", 0)
        #: The type of this message.
        self.type = MessageType(type_)

        #: The true timestamp of this message, a :class:`datetime.datetime`.
        #: This is not the snowflake timestamp.
        self.created_at = to_datetime(kwargs.get("timestamp", None))

        #: The edited timestamp of this message.
        #: This can sometimes be None.
        edited_timestamp = kwargs.get("edited_timestamp", None)
        if edited_timestamp is not None:
            self.edited_at = to_datetime(edited_timestamp)
        else:
            self.edited_at = None

        #: The list of :class:`~.Embed` objects this message contains.
        self.embeds = []
        for embed in kwargs.get("embeds", []):
            self.embeds.append(Embed(**embed))

        #: The list of attachments this message contains.
        self.attachments = []

        for attachment in kwargs.get("attachments", []):
            self.attachments.append(Attachment(**attachment))

        #: The mentions for this message.
        #: This is UNORDERED.
        self._mentions = kwargs.get("mentions", [])

        #: The role mentions for this message.
        #: This is UNORDERED.
        self._role_mentions = kwargs.get("mention_roles", [])

        #: The reactions for this message.
        self.reactions = []
Esempio n. 2
0
    def __init__(self, client, **kwargs):
        super().__init__(kwargs["user"]["id"], client)

        # copy user data for when the user is decached
        self._user_data = kwargs["user"]
        self._bot.state.make_user(self._user_data)

        #: An iterable of role IDs this member has.
        self.role_ids = [int(rid) for rid in kwargs.get("roles", [])]

        #: A :class:`._MemberRoleContainer` that represents the roles of this member.
        self.roles = MemberRoleContainer(self)

        #: The date the user joined the guild.
        self.joined_at = to_datetime(kwargs.get(
            "joined_at", None))  # type: datetime.datetime

        nick = kwargs.get("nick")
        #: The member's current :class:`.Nickname`.
        self._nickname = Nickname(self, nick)  # type: Nickname

        #: The ID of the guild that this member is in.
        self.guild_id = None  # type: int

        #: The current :class:`.Presence` of this member.
        self.presence = Presence(status=kwargs.get("status", Status.OFFLINE),
                                 game=kwargs.get("game", None))
Esempio n. 3
0
    def __init__(self, **kwargs):
        #: The number of times this invite was used.
        self.uses = kwargs.get("uses", 0)  # type: int

        #: The maximum number of uses this invite can use.
        self.max_uses = kwargs.get("max_uses", 0)  # type: int

        #: The maximum age of this invite.
        self.max_age = kwargs.get("max_age", 0)  # type: int

        #: Is this invite temporary?
        self.temporary = kwargs.get("temporary", False)  # type: bool

        #: When was this invite created at?
        self.created_at = util.to_datetime(kwargs.get("created_at", None))

        #: Is this invite revoked?
        self.revoked = kwargs.get("revoked", False)  # type: bool