Skip to content

Commit 5ad2609

Browse files
authored
Merge branch 'master' into get_component
Signed-off-by: Lala Sabathil <[email protected]>
2 parents 5a300cc + 890153a commit 5ad2609

34 files changed

+766
-142
lines changed

.github/dependabot.yml

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

.github/workflows/docs-localization-download.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
working-directory: ./docs
4141
- name: "Crowdin"
4242
id: crowdin
43-
uses: crowdin/github-action@v2.9.1
43+
uses: crowdin/github-action@v2.10.0
4444
with:
4545
upload_sources: false
4646
upload_translations: false

.github/workflows/docs-localization-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
sphinx-intl update -p ./build/locales ${{ vars.SPHINX_LANGUAGES }}
4545
working-directory: ./docs
4646
- name: "Crowdin"
47-
uses: crowdin/github-action@v2.9.1
47+
uses: crowdin/github-action@v2.10.0
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.github/workflows/pr-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: "Check Semantic Pull Request"
28-
uses: amannn/action-semantic-pull-request@v6.0.1
28+
uses: amannn/action-semantic-pull-request@v6.1.1
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.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: 17 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
- Added `get_component` to `Message`, `Section`, `Container` and `ActionRow`.
7379
([#2849](https://github.com/Pycord-Development/pycord/pull/2849))
7480

@@ -142,6 +148,10 @@ These changes are available on the `master` branch, but have not yet been releas
142148
([#2843](https://github.com/Pycord-Development/pycord/pull/2843))
143149
- Fixed `TypeError` when using `@option` with certain annotations and along with
144150
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
151+
- Fixed type-hinting for `PermissionOverwrite.update`.
152+
([#2878](https://github.com/Pycord-Development/pycord/pull/2878))
153+
- Fixed `AttributeError` when accessing `AuditLogEntry.changes` more than once.
154+
([#2882])(https://github.com/Pycord-Development/pycord/pull/2882))
145155

146156
### Changed
147157

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

167179
### Deprecated
168180

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

176191
### Removed
177192

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

1084-
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...HEAD
1099+
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.6.1...HEAD
1100+
[2.6.1]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...v2.6.1
10851101
[2.6.0]: https://github.com/Pycord-Development/pycord/compare/v2.5.0...v2.6.0
10861102
[2.5.0]: https://github.com/Pycord-Development/pycord/compare/v2.4.1...v2.5.0
10871103
[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

0 commit comments

Comments
 (0)