Skip to content

Commit b060522

Browse files
authored
Merge branch 'master' into overlap
2 parents 68f32e4 + 4e853f8 commit b060522

File tree

12 files changed

+280
-80
lines changed

12 files changed

+280
-80
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docs JSON Export
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
export-docs-json:
11+
name: Export docs.json
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
id: checkout
16+
uses: actions/checkout@v5
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
id: setup-python
20+
with:
21+
python-version: "3.13"
22+
cache: "pip"
23+
cache-dependency-path: "requirements/docs.txt"
24+
check-latest: true
25+
- name: Install dependencies
26+
id: install-deps
27+
run: |
28+
python -m pip install -U pip
29+
pip install ".[docs]"
30+
pip install beautifulsoup4
31+
- name: Build Sphinx HTML docs
32+
id: build-sphinx
33+
run: sphinx-build -b html docs docs/_build/html
34+
- name: Export docs.json
35+
id: generate-json
36+
run: python scripts/docs_json_exporter.py
37+
- name: Upload docs.json as artifact
38+
uses: actions/[email protected]
39+
id: artifact-upload
40+
with:
41+
name: Pycord Docs JSON
42+
path: docs.json
43+
retention-days: 1
44+
- name: Show docs.json summary
45+
run: |
46+
head -n 40 docs.json || tail -n 40 docs.json
47+
- name: Output artifact ID
48+
run: |
49+
echo "artifact-id=${{ steps.artifact-upload.outputs.artifact-id }}" >> $GITHUB_OUTPUT
50+
echo "artifact-url=${{ steps.artifact-upload.outputs.artifact-url }}" >> $GITHUB_OUTPUT
51+
echo "::notice::Artifact uploaded: ${{ steps.artifact-upload.outputs.artifact-url }}"

.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.10.0
43+
uses: crowdin/github-action@v2.11.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.10.0
47+
uses: crowdin/github-action@v2.11.0
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.github/workflows/release.yml

Lines changed: 83 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,63 @@ jobs:
4141
env:
4242
VERSION: ${{ github.event.inputs.version }}
4343
run: |
44-
# PEP 440 version regex
4544
VALID_VERSION_REGEX='^([0-9]+\.[0-9]+\.[0-9]+((a|b|rc|\.dev|\.post)[0-9]+)?)$'
4645
if ! [[ $VERSION =~ $VALID_VERSION_REGEX ]]; then
4746
echo "::error::Invalid version string '$VERSION'. Must match PEP 440 (e.g. 1.2.0, 1.2.0rc1, 1.2.0.dev1, 1.2.0a1, 1.2.0b1, 1.2.0.post1)"
4847
exit 1
4948
fi
49+
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$ ]]; then
50+
echo "::error::Unsupported version string '$VERSION'. Only normal releases (e.g. 1.2.3) and rc (e.g. 1.2.3rc1) are supported at this time."
51+
exit 1
52+
fi
5053
echo "version=$VERSION" >> $GITHUB_OUTPUT
5154
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
5255
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
53-
if [[ $VERSION =~ rc[0-9]+$ ]]; then
54-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
55-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
56+
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
57+
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
58+
if [[ $VERSION == *rc* ]]; then
5659
echo "is_rc=true" >> $GITHUB_OUTPUT
57-
elif [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
58-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
59-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
60-
echo "is_rc=false" >> $GITHUB_OUTPUT
6160
else
62-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
63-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
6461
echo "is_rc=false" >> $GITHUB_OUTPUT
6562
fi
6663
64+
branch_protection_rename:
65+
needs: [safety_check]
66+
runs-on: ubuntu-latest
67+
environment: release
68+
env:
69+
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
70+
outputs:
71+
master_rule_id: ${{ steps.get_rule_ids.outputs.master_rule_id }}
72+
master_pattern: ${{ steps.get_rule_ids.outputs.master_pattern }}
73+
v_rule_id: ${{ steps.get_rule_ids.outputs.v_rule_id }}
74+
v_pattern: ${{ steps.get_rule_ids.outputs.v_pattern }}
75+
steps:
76+
- name: Get branch protection rule IDs
77+
id: get_rule_ids
78+
run: |
79+
gh api repos/${{ github.repository }}/branch-protection-rules > rules.json
80+
MASTER_ID=$(jq -r '.[] | select(.pattern == "master") | .id' rules.json)
81+
MASTER_PATTERN=$(jq -r '.[] | select(.pattern == "master") | .pattern' rules.json)
82+
V_ID=$(jq -r '.[] | select(.pattern | test("^v[0-9]+\\.[0-9]+\\.x$")) | .id' rules.json)
83+
V_PATTERN=$(jq -r '.[] | select(.pattern | test("^v[0-9]+\\.[0-9]+\\.x$")) | .pattern' rules.json)
84+
echo "master_rule_id=$MASTER_ID" >> $GITHUB_OUTPUT
85+
echo "master_pattern=$MASTER_PATTERN" >> $GITHUB_OUTPUT
86+
echo "v_rule_id=$V_ID" >> $GITHUB_OUTPUT
87+
echo "v_pattern=$V_PATTERN" >> $GITHUB_OUTPUT
88+
- name: Rename master protection to temp-master
89+
if: ${{ steps.get_rule_ids.outputs.master_rule_id != '' }}
90+
run: |
91+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ steps.get_rule_ids.outputs.master_rule_id }} \
92+
-X PATCH -F pattern="temp-master"
93+
- name: Rename v*.* protection to temp-v
94+
if: ${{ steps.get_rule_ids.outputs.v_rule_id != '' }}
95+
run: |
96+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ steps.get_rule_ids.outputs.v_rule_id }} \
97+
-X PATCH -F pattern="temp-v"
98+
6799
lib_release:
68-
needs: [safety_check,pre_config]
100+
needs: [pre_config, branch_protection_rename]
69101
runs-on: ubuntu-latest
70102
environment: release
71103
env:
@@ -119,7 +151,7 @@ jobs:
119151
DATE=$(date +'%Y-%m-%d')
120152
sed -i "/These changes are available on the \`.*\` branch, but have not yet been released\./{N;d;}" CHANGELOG.md
121153
sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md
122-
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n&|" CHANGELOG.md
154+
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Deprecated\n\n### Removed\n\n&|" CHANGELOG.md
123155
sed -i "s|\[unreleased\]:.*|[unreleased]: https://github.com/$REPOSITORY/compare/v$VERSION...HEAD\n[$VERSION]: https://github.com/$REPOSITORY/compare/$(git describe --tags --abbrev=0 @^)...v$VERSION|" CHANGELOG.md
124156
git add CHANGELOG.md
125157
git commit -m "chore(release): update CHANGELOG.md for version $VERSION"
@@ -193,14 +225,15 @@ jobs:
193225
attestations: false
194226
verify-metadata: false
195227

196-
197228
- name: "Echo release url"
198229
run: echo "${{ steps.gh-release.outputs.url }}"
199230

200231
docs_release:
201232
runs-on: ubuntu-latest
202-
needs: [lib_release,pre_config]
203-
if: ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '0rc1')) }}
233+
needs: [lib_release, pre_config]
234+
if:
235+
${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc
236+
== 'true' && endsWith(needs.pre_config.outputs.version, '0rc1')) }}
204237
environment: release
205238
steps:
206239
- name: "Sync Versions on Read the Docs"
@@ -213,6 +246,7 @@ jobs:
213246
run: |
214247
VERSION=${{ needs.pre_config.outputs.version }}
215248
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
249+
HIDDEN=$([[ $VERSION == *rc* ]] && echo true || echo false)
216250
if [[ $VERSION == *rc* ]]; then
217251
DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
218252
else
@@ -223,48 +257,45 @@ jobs:
223257
--header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" \
224258
--data '{
225259
"active": true,
226-
"hidden": false
260+
"hidden": $HIDDEN
227261
}'
228262
229263
inform_discord:
230264
runs-on: ubuntu-latest
231-
needs: [lib_release,docs_release,pre_config]
265+
needs: [docs_release, lib_release, pre_config]
232266
environment: release
233267
steps:
234268
- name: "Notify Discord"
235269
run: |
236270
VERSION=${{ needs.pre_config.outputs.version }}
237271
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
238-
if [[ $VERSION == *rc* ]]; then
239-
DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
240-
else
241-
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
242-
fi
272+
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
243273
GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
244274
GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
245275
PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
246276
if [[ $VERSION == *rc* ]]; then
247-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
277+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v$VERSION Release Candidate ($MAJOR_MINOR_VERSION) is available!\n\n"
278+
ANNOUNCEMENT="${ANNOUNCEMENT}@here\n\n"
248279
ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
249280
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
250281
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"
251282
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
252-
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!\n@here"
283+
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!"
253284
else
254-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
255-
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
285+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${VERSION} is out!\n\n"
286+
ANNOUNCEMENT="${ANNOUNCEMENT}@everyone\n\n"
256287
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
257288
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"
258-
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
289+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`"
259290
fi
260291
curl -H "Content-Type: application/json" \
261292
-X POST \
262-
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\": [\"everyone\"]}}" \
293+
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\":[\"everyone\",\"roles\"]}}" \
263294
${{ secrets.DISCORD_WEBHOOK_URL }}
264295
265296
determine_milestone_id:
266297
runs-on: ubuntu-latest
267-
needs: [lib_release,pre_config]
298+
needs: [lib_release, pre_config]
268299
if: ${{ !contains(needs.pre_config.outputs.version, '-') }}
269300
outputs:
270301
old_milestone_version: ${{ steps.extract_version.outputs.old_milestone_version }}
@@ -286,8 +317,10 @@ jobs:
286317
287318
close_milestone:
288319
runs-on: ubuntu-latest
289-
needs: [determine_milestone_id,pre_config]
290-
if: ${{ !contains(needs.pre_config.outputs.version, 'rc') && endsWith(needs.pre_config.outputs.version, '.0') }}
320+
needs: [determine_milestone_id, pre_config]
321+
if:
322+
${{ !contains(needs.pre_config.outputs.version, 'rc') &&
323+
endsWith(needs.pre_config.outputs.version, '.0') }}
291324
environment: release
292325
env:
293326
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -308,3 +341,22 @@ jobs:
308341
run: |
309342
gh extension install valeriobelli/gh-milestone
310343
gh milestone create "${{ needs.determine_milestone_id.outputs.new_milestone_version }}"
344+
345+
branch_protection_restore:
346+
runs-on: ubuntu-latest
347+
needs: [branch_protection_rename, lib_release, docs_release, inform_discord, determine_milestone_id, close_milestone]
348+
environment: release
349+
if: always()
350+
env:
351+
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
352+
steps:
353+
- name: Restore master protection pattern
354+
if: ${{ needs.branch_protection_rename.outputs.master_rule_id != '' }}
355+
run: |
356+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ needs.branch_protection_rename.outputs.master_rule_id }} \
357+
-X PATCH -F pattern="${{ needs.branch_protection_rename.outputs.master_pattern }}"
358+
- name: Restore v*.* protection pattern
359+
if: ${{ needs.branch_protection_rename.outputs.v_rule_id != '' }}
360+
run: |
361+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ needs.branch_protection_rename.outputs.v_rule_id }} \
362+
-X PATCH -F pattern="${{ needs.branch_protection_rename.outputs.v_pattern }}"

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ These changes are available on the `master` branch, but have not yet been releas
1212

1313
### Added
1414

15+
- Added `RawMessageUpdateEvent.new_message` - message update events now contain full
16+
message objects ([#2780](https://github.com/Pycord-Development/pycord/pull/2780))
17+
1518
### Changed
1619

1720
### Fixed
1821

22+
- Manage silence for new SSRC with existing user_id.
23+
([#2808](https://github.com/Pycord-Development/pycord/pull/2808))
24+
1925
### Removed
2026

2127
## [2.7.0rc1] - 2025-08-30

discord/commands/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ def __init__(
369369

370370
@staticmethod
371371
def _strip_none_type(input_type):
372+
if isinstance(input_type, SlashCommandOptionType):
373+
return input_type
374+
372375
if input_type is type(None):
373376
raise TypeError("Option type cannot be only NoneType")
374377

discord/message.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,26 +1208,6 @@ def _clear_emoji(self, emoji) -> Reaction | None:
12081208
del self.reactions[index]
12091209
return reaction
12101210

1211-
def _update(self, data):
1212-
# In an update scheme, 'author' key has to be handled before 'member'
1213-
# otherwise they overwrite each other which is undesirable.
1214-
# Since there's no good way to do this we have to iterate over every
1215-
# handler rather than iterating over the keys which is a little slower
1216-
for key, handler in self._HANDLERS:
1217-
try:
1218-
value = data[key]
1219-
except KeyError:
1220-
continue
1221-
else:
1222-
handler(self, value)
1223-
1224-
# clear the cached properties
1225-
for attr in self._CACHED_SLOTS:
1226-
try:
1227-
delattr(self, attr)
1228-
except AttributeError:
1229-
pass
1230-
12311211
def _handle_edited_timestamp(self, value: str) -> None:
12321212
self._edited_timestamp = utils.parse_time(value)
12331213

discord/raw_models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,21 @@ class RawMessageUpdateEvent(_RawReprMixin):
185185
cached_message: Optional[:class:`Message`]
186186
The cached message, if found in the internal message cache. Represents the message before
187187
it is modified by the data in :attr:`RawMessageUpdateEvent.data`.
188+
new_message: :class:`Message`
189+
The new message object. Represents the message after it is modified by the data in
190+
:attr:`RawMessageUpdateEvent.data`.
191+
192+
.. versionadded:: 2.7
188193
"""
189194

190195
__slots__ = ("message_id", "channel_id", "guild_id", "data", "cached_message")
191196

192-
def __init__(self, data: MessageUpdateEvent) -> None:
197+
def __init__(self, data: MessageUpdateEvent, new_message: Message) -> None:
193198
self.message_id: int = int(data["id"])
194199
self.channel_id: int = int(data["channel_id"])
195200
self.data: MessageUpdateEvent = data
196201
self.cached_message: Message | None = None
202+
self.new_message: Message = new_message
197203

198204
try:
199205
self.guild_id: int | None = int(data["guild_id"])

discord/state.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -775,21 +775,19 @@ def parse_message_delete_bulk(self, data) -> None:
775775
self._messages.remove(msg) # type: ignore
776776

777777
def parse_message_update(self, data) -> None:
778-
raw = RawMessageUpdateEvent(data)
779-
message = self._get_message(raw.message_id)
780-
if message is not None:
781-
older_message = copy.copy(message)
782-
raw.cached_message = older_message
783-
self.dispatch("raw_message_edit", raw)
784-
message._update(data)
785-
# Coerce the `after` parameter to take the new updated Member
786-
# ref: #5999
787-
older_message.author = message.author
788-
self.dispatch("message_edit", older_message, message)
778+
old_message = self._get_message(raw.message_id)
779+
if old_message is not None:
780+
self._messages.remove(old_message)
781+
channel, _ = self._get_guild_channel(data)
782+
message = Message(channel=channel, data=data, state=self)
783+
self._messages.append(message)
784+
raw = RawMessageUpdateEvent(data, message)
785+
self.dispatch("raw_message_edit", raw)
786+
if old_message is not None:
787+
self.dispatch("message_edit", old_message, message)
789788
else:
790789
if poll_data := data.get("poll"):
791790
self.store_raw_poll(poll_data, raw)
792-
self.dispatch("raw_message_edit", raw)
793791

794792
if "components" in data and self._view_store.is_message_tracked(raw.message_id):
795793
self._view_store.update_from_message(raw.message_id, data["components"])

0 commit comments

Comments
 (0)