Skip to content

Commit 9746527

Browse files
authored
Merge branch 'master' into JL710/permission-update-typing
Signed-off-by: Paillat <[email protected]>
2 parents e72c7a5 + 76f91b0 commit 9746527

29 files changed

+757
-135
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@ jobs:
7070
with:
7171
fetch-depth: 0
7272
fetch-tags: true
73-
73+
- name: "Create version branch if missing"
74+
id: conditional-create-version-branch
75+
shell: bash
76+
env:
77+
VERSION_BRANCH: ${{ needs.pre_config.outputs.branch_name }}
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: |
80+
git fetch origin
81+
if ! git show-ref --verify --quiet refs/heads/$VERSION_BRANCH; then
82+
git checkout -b $VERSION_BRANCH
83+
git push origin $VERSION_BRANCH
84+
fi
85+
git checkout $VERSION_BRANCH
7486
- name: "Release Pycord"
7587
id: pycord-release
7688
uses: Aiko-IT-Systems/[email protected]
@@ -92,7 +104,7 @@ jobs:
92104
docs_release:
93105
runs-on: ubuntu-latest
94106
needs: [lib_release,pre_config]
95-
if: needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc1'))
107+
if: ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc.1')) }}
96108
environment: release
97109
steps:
98110
- name: "Sync Versions on Read the Docs"
@@ -105,11 +117,10 @@ jobs:
105117
run: |
106118
VERSION=${{ needs.pre_config.outputs.version }}
107119
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
108-
PATCH_VERSION=${VERSION##*.}
109-
if [[ $PATCH_VERSION =~ ^[0-9]+$ ]]; then
110-
DOCS_VERSION="v$VERSION"
120+
if [[ $VERSION == *-rc* ]]; then
121+
DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
111122
else
112-
DOCS_VERSION="v$MAJOR_MINOR_VERSION.x"
123+
DOCS_VERSION="v$VERSION"
113124
fi
114125
curl --location --request PATCH "https://readthedocs.org/api/v3/projects/pycord/versions/$DOCS_VERSION/" \
115126
--header 'Content-Type: application/json' \
@@ -128,24 +139,37 @@ jobs:
128139
run: |
129140
VERSION=${{ needs.pre_config.outputs.version }}
130141
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
131-
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
142+
if [[ $VERSION == *-rc* ]]; then
143+
DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
144+
else
145+
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
146+
fi
132147
GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
133148
GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
134149
PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
135-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
136-
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
137-
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
138-
ANNOUNCEMENT="${ANNOUNCEMENT}Feel free to take a look at the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL) and the [PyPI release page]($PYPI_RELEASE_URL).\n\n"
139-
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
150+
if [[ $VERSION == *-rc* ]]; then
151+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
152+
ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
153+
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
154+
ANNOUNCEMENT="${ANNOUNCEMENT}Check out the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL), and [PyPI release page]($PYPI_RELEASE_URL).\n\n"
155+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
156+
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!\n@here"
157+
else
158+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
159+
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
160+
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
161+
ANNOUNCEMENT="${ANNOUNCEMENT}Feel free to take a look at the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL) and the [PyPI release page]($PYPI_RELEASE_URL).\n\n"
162+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
163+
fi
140164
curl -H "Content-Type: application/json" \
141165
-X POST \
142-
-d "{\"content\":\"$ANNOUNCEMENT\"}" \
166+
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\": [\"everyone\"]}}" \
143167
${{ secrets.DISCORD_WEBHOOK_URL }}
144168
145169
determine_milestone_id:
146170
runs-on: ubuntu-latest
147171
needs: [lib_release,pre_config]
148-
if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
172+
if: ${{ !contains(needs.pre_config.outputs.version, '-') }}
149173
outputs:
150174
old_milestone_version: ${{ steps.extract_version.outputs.old_milestone_version }}
151175
new_milestone_version: ${{ steps.extract_version.outputs.new_milestone_version }}
@@ -158,7 +182,8 @@ jobs:
158182
run: |
159183
gh extension install valeriobelli/gh-milestone
160184
VERSION=${{ needs.pre_config.outputs.version }}
161-
OLD_MILESTONE_VERSION=$(gh milestone list --query "v2.7" | grep "#" | awk '{print $2}')
185+
PREV_MAJOR_MINOR=$(echo $VERSION | awk -F. '{printf "v%d.%d", $1, $2-1}')
186+
OLD_MILESTONE_VERSION=$(gh milestone list --query "$PREV_MAJOR_MINOR" | grep "#" | awk '{print $2}')
162187
NEW_MILESTONE_VERSION="v$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')"
163188
echo "old_milestone_version=$OLD_MILESTONE_VERSION" >> $GITHUB_OUTPUT
164189
echo "new_milestone_version=$NEW_MILESTONE_VERSION" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ cython_debug/
159159

160160
# Custom
161161
*.json
162+
!renovate.json
162163
*.egg-info
163164
.venv/
164165
docs/_build
@@ -192,3 +193,4 @@ docs/build/linkcheck
192193
!docs/locales/*
193194
/build/
194195
/vscode/
196+
remote-release.yml

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ These changes are available on the `master` branch, but have not yet been releas
6969
([#2818](https://github.com/Pycord-Development/pycord/pull/2818))
7070
- Added `Interaction.attachment_size_limit`.
7171
([#2854](https://github.com/Pycord-Development/pycord/pull/2854))
72+
- Added support for selects and text displays in modals.
73+
([#2858](https://github.com/Pycord-Development/pycord/pull/2858))
74+
- Added `AuditLogDiff.communication_disabled_until`.
75+
([#2883](https://github.com/Pycord-Development/pycord/pull/2883))
76+
- Added `discord.User.primary_guild` and the `PrimaryGuild` class.
77+
([#2876](https://github.com/Pycord-Development/pycord/pull/2876))
7278

7379
### Fixed
7480

@@ -142,6 +148,8 @@ These changes are available on the `master` branch, but have not yet been releas
142148
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
143149
- Fixed type hint for `PermissionOverwrite.update`
144150
([#2878](https://github.com/Pycord-Development/pycord/pull/2878))
151+
- Fixed `AttributeError` when accessing `AuditLogEntry.changes` more than once.
152+
([#2882])(https://github.com/Pycord-Development/pycord/pull/2882))
145153

146154
### Changed
147155

@@ -163,6 +171,8 @@ These changes are available on the `master` branch, but have not yet been releas
163171
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
164172
- Upgraded voice websocket version to v8.
165173
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
174+
- `Messageable.pins()` now returns a `MessagePinIterator` and has new arguments.
175+
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))
166176

167177
### Deprecated
168178

@@ -172,6 +182,9 @@ These changes are available on the `master` branch, but have not yet been releas
172182
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
173183
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
174184
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
185+
- Deprecated `Messageable.pins()` returning a list of `Message`; it should be used as an
186+
iterator of `MessagePin` instead.
187+
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))
175188

176189
### Removed
177190

@@ -1081,7 +1094,8 @@ These changes are available on the `master` branch, but have not yet been releas
10811094
- Fix py3.10 UnionType checks issue.
10821095
([#1240](https://github.com/Pycord-Development/pycord/pull/1240))
10831096

1084-
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...HEAD
1097+
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.6.1...HEAD
1098+
[2.6.1]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...v2.6.1
10851099
[2.6.0]: https://github.com/Pycord-Development/pycord/compare/v2.5.0...v2.6.0
10861100
[2.5.0]: https://github.com/Pycord-Development/pycord/compare/v2.4.1...v2.5.0
10871101
[2.4.1]: https://github.com/Pycord-Development/pycord/compare/v2.4.0...v2.4.1

discord/abc.py

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from .file import File, VoiceMessage
4949
from .flags import ChannelFlags, MessageFlags
5050
from .invite import Invite
51-
from .iterators import HistoryIterator
51+
from .iterators import HistoryIterator, MessagePinIterator
5252
from .mentions import AllowedMentions
5353
from .partial_emoji import PartialEmoji, _EmojiTag
5454
from .permissions import PermissionOverwrite, Permissions
@@ -1754,32 +1754,64 @@ async def fetch_message(self, id: int, /) -> Message:
17541754
data = await self._state.http.get_message(channel.id, id)
17551755
return self._state.create_message(channel=channel, data=data)
17561756

1757-
async def pins(self) -> list[Message]:
1758-
"""|coro|
1757+
def pins(
1758+
self,
1759+
*,
1760+
limit: int | None = 50,
1761+
before: SnowflakeTime | None = None,
1762+
) -> MessagePinIterator:
1763+
"""Returns a :class:`~discord.MessagePinIterator` that enables receiving the destination's pinned messages.
17591764
1760-
Retrieves all messages that are currently pinned in the channel.
1765+
You must have :attr:`~discord.Permissions.read_message_history` permissions to use this.
17611766
1762-
.. note::
1767+
.. warning::
17631768
1764-
Due to a limitation with the Discord API, the :class:`.Message`
1765-
objects returned by this method do not contain complete
1766-
:attr:`.Message.reactions` data.
1769+
Starting from version 3.0, `await channel.pins()` will no longer return a list of :class:`Message`. See examples below for new usage instead.
17671770
1768-
Returns
1769-
-------
1770-
List[:class:`~discord.Message`]
1771-
The messages that are currently pinned.
1771+
Parameters
1772+
----------
1773+
limit: Optional[:class:`int`]
1774+
The number of pinned messages to retrieve.
1775+
If ``None``, retrieves every pinned message in the channel.
1776+
before: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
1777+
Retrieve messages pinned before this datetime.
1778+
If a datetime is provided, it is recommended to use a UTC aware datetime.
1779+
If the datetime is naive, it is assumed to be local time.
1780+
1781+
Yields
1782+
------
1783+
:class:`~discord.MessagePin`
1784+
The pinned message.
17721785
17731786
Raises
17741787
------
1788+
~discord.Forbidden
1789+
You do not have permissions to get pinned messages.
17751790
~discord.HTTPException
1776-
Retrieving the pinned messages failed.
1777-
"""
1791+
The request to get pinned messages failed.
17781792
1779-
channel = await self._get_channel()
1780-
state = self._state
1781-
data = await state.http.pins_from(channel.id)
1782-
return [state.create_message(channel=channel, data=m) for m in data]
1793+
Examples
1794+
--------
1795+
1796+
Usage ::
1797+
1798+
counter = 0
1799+
async for pin in channel.pins(limit=250):
1800+
if pin.message.author == client.user:
1801+
counter += 1
1802+
1803+
Flattening into a list: ::
1804+
1805+
pins = await channel.pins(limit=None).flatten()
1806+
# pins is now a list of MessagePin...
1807+
1808+
All parameters are optional.
1809+
"""
1810+
return MessagePinIterator(
1811+
self,
1812+
limit=limit,
1813+
before=before,
1814+
)
17831815

17841816
def can_send(self, *objects) -> bool:
17851817
"""Returns a :class:`bool` indicating whether you have the permissions to send the object(s).

discord/asset.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
if TYPE_CHECKING:
4040
ValidStaticFormatTypes = Literal["webp", "jpeg", "jpg", "png"]
4141
ValidAssetFormatTypes = Literal["webp", "jpeg", "jpg", "png", "gif"]
42+
from .state import ConnectionState
43+
4244

4345
VALID_STATIC_FORMATS = frozenset({"jpeg", "jpg", "webp", "png"})
4446
VALID_ASSET_FORMATS = VALID_STATIC_FORMATS | {"gif"}
@@ -201,6 +203,33 @@ def _from_avatar_decoration(
201203
animated=animated,
202204
)
203205

206+
@classmethod
207+
def _from_user_primary_guild_tag(
208+
cls, state: ConnectionState, identity_guild_id: int, badge_id: str
209+
) -> Asset:
210+
"""Creates an Asset for a user's primary guild (tag) badge.
211+
212+
Parameters
213+
----------
214+
state: ConnectionState
215+
The connection state.
216+
identity_guild_id: int
217+
The ID of the guild.
218+
badge_id: str
219+
The badge hash/id.
220+
221+
Returns
222+
-------
223+
:class:`Asset`
224+
The primary guild badge asset.
225+
"""
226+
return cls(
227+
state,
228+
url=f"{Asset.BASE}/guild-tag-badges/{identity_guild_id}/{badge_id}.png?size=256",
229+
key=badge_id,
230+
animated=False,
231+
)
232+
204233
@classmethod
205234
def _from_guild_avatar(
206235
cls, state, guild_id: int, member_id: int, avatar: str

discord/audit_logs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
from __future__ import annotations
2727

28+
import datetime
29+
from functools import cached_property
2830
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generator, TypeVar
2931

3032
from . import enums, utils
@@ -44,8 +46,6 @@
4446

4547

4648
if TYPE_CHECKING:
47-
import datetime
48-
4949
from . import abc
5050
from .emoji import GuildEmoji
5151
from .guild import Guild
@@ -209,6 +209,14 @@ def _transform_trigger_metadata(
209209
return AutoModTriggerMetadata.from_dict(data)
210210

211211

212+
def _transform_communication_disabled_until(
213+
entry: AuditLogEntry, data: str
214+
) -> datetime.datetime | None:
215+
if data:
216+
return datetime.datetime.fromisoformat(data)
217+
return None
218+
219+
212220
class AuditLogDiff:
213221
def __len__(self) -> int:
214222
return len(self.__dict__)
@@ -281,6 +289,7 @@ class AuditLogChanges:
281289
"trigger_metadata": (None, _transform_trigger_metadata),
282290
"exempt_roles": (None, _transform_roles),
283291
"exempt_channels": (None, _transform_channels),
292+
"communication_disabled_until": (None, _transform_communication_disabled_until),
284293
}
285294

286295
def __init__(
@@ -636,7 +645,7 @@ def category(self) -> enums.AuditLogActionCategory:
636645
"""The category of the action, if applicable."""
637646
return self.action.category
638647

639-
@property
648+
@cached_property
640649
def changes(self) -> AuditLogChanges:
641650
"""The list of changes this entry has."""
642651
obj = AuditLogChanges(self, self._changes, state=self._state)

discord/collectibles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class Nameplate:
3939
4040
Attributes
4141
----------
42-
sku_id: int
43-
The SKU ID of the nameplate.
44-
palette: str
45-
The color palette of the nameplate.
42+
sku_id: :class:`int`
43+
The SKU ID of the nameplate.
44+
palette: :class:`str`
45+
The color palette of the nameplate.
4646
"""
4747

4848
def __init__(self, data: NameplatePayload, state: "ConnectionState") -> None:

0 commit comments

Comments
 (0)