Beispiel #1
0
 def event(self):
     return message_events.GuildMessageDeleteEvent(
         app=None,
         message=mock.Mock(spec_set=messages.Message,
                           guild_id=snowflakes.Snowflake(9182736)),
         shard=object(),
     )
Beispiel #2
0
    def deserialize_message_delete_event(
        self,
        shard: gateway_shard.GatewayShard,
        payload: data_binding.JSONObject,
        *,
        old_message: typing.Optional[messages_models.Message],
    ) -> message_events.MessageDeleteEvent:
        channel_id = snowflakes.Snowflake(payload["channel_id"])
        message_id = snowflakes.Snowflake(payload["id"])

        if "guild_id" in payload:
            return message_events.GuildMessageDeleteEvent(
                app=self._app,
                shard=shard,
                channel_id=channel_id,
                message_id=message_id,
                guild_id=snowflakes.Snowflake(payload["guild_id"]),
                old_message=old_message,
            )

        return message_events.DMMessageDeleteEvent(
            app=self._app,
            shard=shard,
            channel_id=channel_id,
            message_id=message_id,
            old_message=old_message,
        )
Beispiel #3
0
    def deserialize_message_delete_bulk_event(
            self, shard: gateway_shard.GatewayShard,
            payload: data_binding.JSONObject
    ) -> message_events.MessageDeleteEvent:

        message_ids = collections.SnowflakeSet(
            *(snowflakes.Snowflake(message_id)
              for message_id in payload["ids"]))
        channel_id = snowflakes.Snowflake(payload["channel_id"])

        if "guild_id" in payload:
            return message_events.GuildMessageDeleteEvent(
                app=self._app,
                shard=shard,
                channel_id=channel_id,
                guild_id=snowflakes.Snowflake(payload["guild_id"]),
                message_ids=message_ids,
                is_bulk=True,
            )

        return message_events.DMMessageDeleteEvent(app=self._app,
                                                   shard=shard,
                                                   channel_id=channel_id,
                                                   message_ids=message_ids,
                                                   is_bulk=True)
Beispiel #4
0
 def event(self):
     return message_events.GuildMessageDeleteEvent(
         guild_id=snowflakes.Snowflake(542342354564),
         channel_id=snowflakes.Snowflake(54213123123),
         app=mock.Mock(),
         shard=mock.Mock(),
         message_ids={9, 18, 27, 36},
         is_bulk=True,
     )
 def event(self):
     return message_events.GuildMessageDeleteEvent(
         guild_id=snowflakes.Snowflake(542342354564),
         channel_id=snowflakes.Snowflake(54213123123),
         app=mock.Mock(),
         shard=object(),
         message_id=9,
         old_message=object(),
     )
Beispiel #6
0
    def deserialize_message_delete_event(
            self, shard: gateway_shard.GatewayShard,
            payload: data_binding.JSONObject
    ) -> message_events.MessageDeleteEvent:
        message = self._app.entity_factory.deserialize_partial_message(payload)

        if message.guild_id is None:
            return message_events.PrivateMessageDeleteEvent(app=self._app,
                                                            shard=shard,
                                                            message=message)

        return message_events.GuildMessageDeleteEvent(app=self._app,
                                                      shard=shard,
                                                      message=message)