Skip to content

Commit 49c7944

Browse files
authored
Merge branch 'master' into feat/bypass-slowmode
Signed-off-by: Lala Sabathil <lala@pycord.dev>
2 parents 8fe3bf4 + e27ff1d commit 49c7944

37 files changed

+665
-59
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
- name: "Checkout repository"
2929
uses: actions/checkout@v5
3030
- name: "Initialize CodeQL"
31-
uses: github/codeql-action/init@v3
31+
uses: github/codeql-action/init@v4
3232
with:
3333
languages: ${{ matrix.language }}
3434
- name: "Autobuild"
35-
uses: github/codeql-action/autobuild@v3
35+
uses: github/codeql-action/autobuild@v4
3636
- name: "Perform CodeQL Analysis"
37-
uses: github/codeql-action/analyze@v3
37+
uses: github/codeql-action/analyze@v4

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

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
python3 -m build --sdist
199199
python3 -m build --wheel
200200
- name: "Create GitHub Release"
201-
uses: softprops/action-gh-release@v2.3.3
201+
uses: softprops/action-gh-release@v2.4.1
202202
id: gh-release
203203
with:
204204
tag_name: "v${{ inputs.version }}"

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ repos:
2121
# - --remove-duplicate-keys
2222
# - --remove-unused-variables
2323
- repo: https://github.com/asottile/pyupgrade
24-
rev: v3.20.0
24+
rev: v3.21.0
2525
hooks:
2626
- id: pyupgrade
2727
exclude: \.(po|pot|yml|yaml)$
2828
- repo: https://github.com/PyCQA/isort
29-
rev: 6.0.1
29+
rev: 7.0.0
3030
hooks:
3131
- id: isort
3232
exclude: \.(po|pot|yml|yaml)$
33-
- repo: https://github.com/psf/black
34-
rev: 25.1.0
33+
- repo: https://github.com/psf/black-pre-commit-mirror
34+
rev: 25.9.0
3535
hooks:
3636
- id: black
3737
args: [--safe, --quiet]

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ These changes are available on the `master` branch, but have not yet been releas
2828
- Adds pre-typed and pre-constructed with select_type `ui.Select` aliases for the
2929
different select types: `ui.StringSelect`, `ui.UserSelect`, `ui.RoleSelect`,
3030
`ui.MentionableSelect`, and `ui.ChannelSelect`.
31+
- Added `ui.FileUpload` for modals and the `FileUpload` component.
32+
([#2938](https://github.com/Pycord-Development/pycord/pull/2938))
3133
- Added `Permissions.bypass_slowmode`.
3234
([#2939](https://github.com/Pycord-Development/pycord/pull/2939))
3335

@@ -47,6 +49,15 @@ These changes are available on the `master` branch, but have not yet been releas
4749
([#2924](https://github.com/Pycord-Development/pycord/pull/2924))
4850
- Fixed OPUS Decode Error when recording audio.
4951
([#2925](https://github.com/Pycord-Development/pycord/pull/2925))
52+
- Fixed a `TypeError` when typing `ui.Select` without providing optional type arguments.
53+
([#2943](https://github.com/Pycord-Development/pycord/pull/2943))
54+
- Fixed modal input values being misordered when using the `row` parameter and inserting
55+
items out of row order.
56+
([#2938](https://github.com/Pycord-Development/pycord/pull/2938))
57+
- Fixed a KeyError when a text input is left blank in a modal.
58+
([#2938](https://github.com/Pycord-Development/pycord/pull/2938))
59+
- Fixed `TypeError` when using Python 3.12+ `type` syntax for typing slash command
60+
parameters. ([#2952](https://github.com/Pycord-Development/pycord/pull/2952))
5061

5162
### Removed
5263

@@ -108,6 +119,9 @@ These changes are available on the `master` branch, but have not yet been releas
108119
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
109120
- Added the ability to pass a `datetime.time` object to `format_dt`.
110121
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
122+
- Added the ability to pass an `overlap` parameter to the `loop` decorator and `Loop`
123+
class, allowing concurrent iterations if enabled.
124+
([#2765](https://github.com/Pycord-Development/pycord/pull/2765))
111125
- Added various missing channel parameters and allow `default_reaction_emoji` to be
112126
`None`. ([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
113127
- Added support for type hinting slash command options with `typing.Annotated`.

discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from .flags import *
4848
from .guild import *
4949
from .http import *
50+
from .incidents import *
5051
from .integrations import *
5152
from .interactions import *
5253
from .invite import *

discord/channel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,9 +2909,7 @@ def __init__(
29092909
self._update(guild, data)
29102910

29112911
def __repr__(self) -> str:
2912-
return (
2913-
f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}"
2914-
)
2912+
return f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}>"
29152913

29162914
def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
29172915
# This data will always exist

discord/commands/options.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
import logging
2929
import types
3030
from enum import Enum
31-
from typing import TYPE_CHECKING, Literal, Optional, Type, Union, get_args
31+
from typing import (
32+
TYPE_CHECKING,
33+
Literal,
34+
Optional,
35+
Type,
36+
TypeAliasType,
37+
Union,
38+
get_args,
39+
)
3240

3341
from ..abc import GuildChannel, Mentionable
3442
from ..channel import (
@@ -197,6 +205,7 @@ def __init__(
197205
if self.name is not None:
198206
self.name = str(self.name)
199207
self._parameter_name = self.name # default
208+
input_type = self._parse_type_alias(input_type)
200209
input_type = self._strip_none_type(input_type)
201210
self._raw_type: InputType | tuple = input_type
202211

@@ -367,6 +376,12 @@ def __init__(
367376
if input_type is None:
368377
raise TypeError("input_type cannot be NoneType.")
369378

379+
@staticmethod
380+
def _parse_type_alias(input_type: InputType) -> InputType:
381+
if isinstance(input_type, TypeAliasType):
382+
return input_type.__value__
383+
return input_type
384+
370385
@staticmethod
371386
def _strip_none_type(input_type):
372387
if isinstance(input_type, SlashCommandOptionType):

discord/components.py

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .types.components import Component as ComponentPayload
5151
from .types.components import ContainerComponent as ContainerComponentPayload
5252
from .types.components import FileComponent as FileComponentPayload
53+
from .types.components import FileUploadComponent as FileUploadComponentPayload
5354
from .types.components import InputText as InputTextComponentPayload
5455
from .types.components import LabelComponent as LabelComponentPayload
5556
from .types.components import MediaGalleryComponent as MediaGalleryComponentPayload
@@ -81,6 +82,7 @@
8182
"Container",
8283
"Label",
8384
"SelectDefaultValue",
85+
"FileUpload",
8486
)
8587

8688
C = TypeVar("C", bound="Component")
@@ -938,7 +940,6 @@ def url(self, value: str) -> None:
938940

939941
@classmethod
940942
def from_dict(cls, data: UnfurledMediaItemPayload, state=None) -> UnfurledMediaItem:
941-
942943
r = cls(data.get("url"))
943944
r.proxy_url = data.get("proxy_url")
944945
r.height = data.get("height")
@@ -1347,6 +1348,71 @@ def walk_components(self) -> Iterator[Component]:
13471348
yield from [self.component]
13481349

13491350

1351+
class FileUpload(Component):
1352+
"""Represents an File Upload component from the Discord Bot UI Kit.
1353+
1354+
This inherits from :class:`Component`.
1355+
1356+
.. note::
1357+
1358+
This class is not useable by end-users; see :class:`discord.ui.FileUpload` instead.
1359+
1360+
.. versionadded:: 2.7
1361+
1362+
Attributes
1363+
----------
1364+
custom_id: Optional[:class:`str`]
1365+
The custom ID of the file upload field that gets received during an interaction.
1366+
min_values: Optional[:class:`int`]
1367+
The minimum number of files that must be uploaded.
1368+
max_values: Optional[:class:`int`]
1369+
The maximum number of files that can be uploaded.
1370+
required: Optional[:class:`bool`]
1371+
Whether the file upload field is required or not. Defaults to `True`.
1372+
id: Optional[:class:`int`]
1373+
The file upload's ID.
1374+
"""
1375+
1376+
__slots__: tuple[str, ...] = (
1377+
"type",
1378+
"custom_id",
1379+
"min_values",
1380+
"max_values",
1381+
"required",
1382+
"id",
1383+
)
1384+
1385+
__repr_info__: ClassVar[tuple[str, ...]] = __slots__
1386+
versions: tuple[int, ...] = (1, 2)
1387+
1388+
def __init__(self, data: FileUploadComponentPayload):
1389+
self.type = ComponentType.file_upload
1390+
self.id: int | None = data.get("id")
1391+
self.custom_id = data["custom_id"]
1392+
self.min_values: int | None = data.get("min_values", None)
1393+
self.max_values: int | None = data.get("max_values", None)
1394+
self.required: bool = data.get("required", True)
1395+
1396+
def to_dict(self) -> FileUploadComponentPayload:
1397+
payload = {
1398+
"type": 19,
1399+
"custom_id": self.custom_id,
1400+
}
1401+
if self.id is not None:
1402+
payload["id"] = self.id
1403+
1404+
if self.min_values is not None:
1405+
payload["min_values"] = self.min_values
1406+
1407+
if self.max_values is not None:
1408+
payload["max_values"] = self.max_values
1409+
1410+
if not self.required:
1411+
payload["required"] = self.required
1412+
1413+
return payload # type: ignore
1414+
1415+
13501416
COMPONENT_MAPPINGS = {
13511417
1: ActionRow,
13521418
2: Button,
@@ -1364,6 +1430,7 @@ def walk_components(self) -> Iterator[Component]:
13641430
14: Separator,
13651431
17: Container,
13661432
18: Label,
1433+
19: FileUpload,
13671434
}
13681435

13691436
STATE_COMPONENTS = (Section, Container, Thumbnail, MediaGallery, FileComponent)

0 commit comments

Comments
 (0)