Set the pin state of a submission on the authenticated user's profile. :param submission: An instance of :class:`.Submission` that will be pinned/unpinned. :param num: If specified, the slot in which the submission will be pinned into. If there is a submissio
(
self, submission: models.Submission, *, num: int | None = None, state: bool = True
)
| 169 | return self._reddit.get(API_PATH["my_multireddits"]) |
| 170 | |
| 171 | def pin( |
| 172 | self, submission: models.Submission, *, num: int | None = None, state: bool = True |
| 173 | ) -> models.Submission | None: |
| 174 | """Set the pin state of a submission on the authenticated user's profile. |
| 175 | |
| 176 | :param submission: An instance of :class:`.Submission` that will be |
| 177 | pinned/unpinned. |
| 178 | :param num: If specified, the slot in which the submission will be pinned into. |
| 179 | If there is a submission already in the specified slot, it will be replaced. |
| 180 | If ``None`` or there is not a submission in the specified slot, the first |
| 181 | available slot will be used (default: ``None``). If all slots are used the |
| 182 | following will occur: |
| 183 | |
| 184 | - Old Reddit: |
| 185 | |
| 186 | 1. The submission in the last slot will be unpinned. |
| 187 | 2. The remaining pinned submissions will be shifted down a slot. |
| 188 | 3. The new submission will be pinned in the first slot. |
| 189 | |
| 190 | - New Reddit: |
| 191 | |
| 192 | 1. The submission in the first slot will be unpinned. |
| 193 | 2. The remaining pinned submissions will be shifted up a slot. |
| 194 | 3. The new submission will be pinned in the last slot. |
| 195 | |
| 196 | .. note:: |
| 197 | |
| 198 | At the time of writing (10/22/2021), there are 4 pin slots available and |
| 199 | pins are in reverse order on old Reddit. If ``num`` is an invalid value, |
| 200 | Reddit will ignore it and the same behavior will occur as if ``num`` is |
| 201 | ``None``. |
| 202 | |
| 203 | :param state: ``True`` pins the submission, ``False`` unpins (default: |
| 204 | ``True``). |
| 205 | |
| 206 | :returns: The pinned submission. |
| 207 | |
| 208 | :raises: ``prawcore.BadRequest`` when pinning a removed or deleted submission. |
| 209 | :raises: ``prawcore.Forbidden`` when pinning a submission the authenticated user |
| 210 | is not the author of. |
| 211 | |
| 212 | .. code-block:: python |
| 213 | |
| 214 | submission = next(reddit.user.me().submissions.new()) |
| 215 | reddit.user.pin(submission) |
| 216 | |
| 217 | """ |
| 218 | data = { |
| 219 | "id": submission.fullname, |
| 220 | "num": num, |
| 221 | "state": state, |
| 222 | "to_profile": True, |
| 223 | } |
| 224 | try: |
| 225 | return self._reddit.post(API_PATH["sticky_submission"], data=data) |
| 226 | except Conflict: |
| 227 | pass |
| 228 |