Skip to content

Commit 88b5943

Browse files
committed
Merge branch 'master' into features/voice-receive
2 parents 740c41e + e58dd4d commit 88b5943

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3471
-1443
lines changed

.github/CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Generally speaking questions are better suited in our resources below.
1111
- The official support server: https://discord.gg/UCXwPR7Pew
1212
- The Discord API server under #python_discord-py: https://discord.gg/discord-api
1313
- [The FAQ in the documentation](https://docs.pycord.dev/en/master/faq.html)
14-
- [StackOverflow's `discord.py` tag](https://stackoverflow.com/questions/tagged/discord.py)
14+
- [StackOverflow's `pycord` tag](https://stackoverflow.com/questions/tagged/pycord)
1515

1616
Please try your best not to ask questions in our issue tracker. Most of them don't belong there unless they provide value to a larger audience.
1717

@@ -43,12 +43,14 @@ deciding to ignore type checking warnings.
4343

4444
By submitting a pull request, you agree that; 1) You hold the copyright on all submitted code inside said pull request; 2) You agree to transfer all rights to the owner of this repository, and; 3) If you are found to be in fault with any of the above, we shall not be held responsible in any way after the pull request has been merged.
4545

46-
### Git Commit Guidelines
46+
## Git Commit Styling
4747

48-
- Use present tense (e.g. "Add feature" not "Added feature")
49-
- Limit all lines to 72 characters or less.
50-
- Reference issues or pull requests outside of the first line.
51-
- Please use the shorthand `#123` and not the full URL.
52-
- Commits regarding the commands extension must be prefixed with `[commands]`
48+
Not following this guideline could lead to your pull being squashed for a cleaner commit history
5349

54-
If you do not meet any of these guidelines, don't fret. Chances are they will be fixed upon rebasing but please do try to meet them to remove some of the workload.
50+
Some style guides we would recommed using in your pulls:
51+
52+
The [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) style is a very widely used style and a good style to start with.
53+
54+
The [gitmoji](https://gitmoji.dev) style guide would make your pull look more lively and different to others.
55+
56+
We don't limit nor deny your pulls when you're using another style although, please make sure it is appropriate and makes sense in this library.

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ body:
1717
- The core library
1818
- discord.ext.commands
1919
- discord.ext.tasks
20+
- discord.ext.pages
2021
- The documentation
2122
validations:
2223
required: true

discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from .commands import *
6565
from .cog import Cog
6666
from .welcome_screen import *
67+
from .scheduled_events import ScheduledEvent, ScheduledEventLocation
6768

6869

6970
class VersionInfo(NamedTuple):

discord/abc.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
runtime_checkable,
4444
)
4545

46+
from .scheduled_events import ScheduledEvent
4647
from .iterators import HistoryIterator
4748
from .context_managers import Typing
4849
from .enums import ChannelType
@@ -211,10 +212,10 @@ def _asdict(self) -> PermissionOverwritePayload:
211212
}
212213

213214
def is_role(self) -> bool:
214-
return self.type == 0
215+
return self.type == self.ROLE
215216

216217
def is_member(self) -> bool:
217-
return self.type == 1
218+
return self.type == self.MEMBER
218219

219220

220221
GCH = TypeVar('GCH', bound='GuildChannel')
@@ -1035,6 +1036,7 @@ async def create_invite(
10351036
max_uses: int = 0,
10361037
temporary: bool = False,
10371038
unique: bool = True,
1039+
target_event: Optional[ScheduledEvent] = None,
10381040
target_type: Optional[InviteTarget] = None,
10391041
target_user: Optional[User] = None,
10401042
target_application_id: Optional[int] = None,
@@ -1073,11 +1075,20 @@ async def create_invite(
10731075
10741076
.. versionadded:: 2.0
10751077
1076-
target_application_id:: Optional[:class:`int`]
1078+
target_application_id: Optional[:class:`int`]
10771079
The id of the embedded application for the invite, required if `target_type` is `TargetType.embedded_application`.
10781080
10791081
.. versionadded:: 2.0
10801082
1083+
target_event: Optional[:class:`ScheduledEvent`]
1084+
The scheduled event object to link to the event.
1085+
Shortcut to :meth:`Invite.set_scheduled_event`
1086+
1087+
See :meth:`Invite.set_scheduled_event` for more
1088+
info on event invite linking.
1089+
1090+
.. versionadded:: 2.0
1091+
10811092
Raises
10821093
-------
10831094
~discord.HTTPException
@@ -1103,7 +1114,10 @@ async def create_invite(
11031114
target_user_id=target_user.id if target_user else None,
11041115
target_application_id=target_application_id,
11051116
)
1106-
return Invite.from_incomplete(data=data, state=self._state)
1117+
invite = Invite.from_incomplete(data=data, state=self._state)
1118+
if target_event:
1119+
invite.set_scheduled_event(target_event)
1120+
return invite
11071121

11081122
async def invites(self) -> List[Invite]:
11091123
"""|coro|

discord/asset.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,17 @@ def _from_cover_image(cls, state, object_id: int, cover_image_hash: str) -> Asse
209209

210210
@classmethod
211211
def _from_guild_image(cls, state, guild_id: int, image: str, path: str) -> Asset:
212+
animated = False
213+
format = "png"
214+
if path == "banners":
215+
animated = image.startswith("a_")
216+
format = "gif" if animated else "png"
217+
212218
return cls(
213219
state,
214-
url=f'{cls.BASE}/{path}/{guild_id}/{image}.png?size=1024',
220+
url=f"{cls.BASE}/{path}/{guild_id}/{image}.{format}?size=1024",
215221
key=image,
216-
animated=False,
222+
animated=animated,
217223
)
218224

219225
@classmethod

discord/audit_logs.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
from .stage_instance import StageInstance
6262
from .sticker import GuildSticker
6363
from .threads import Thread
64+
from .scheduled_events import ScheduledEvent
65+
from .state import ConnectionState
6466

6567

6668
def _transform_permissions(entry: AuditLogEntry, data: str) -> Permissions:
@@ -147,7 +149,7 @@ def _transform(entry: AuditLogEntry, data: int) -> T:
147149

148150
return _transform
149151

150-
def _transform_type(entry: AuditLogEntry, data: Union[int]) -> Union[enums.ChannelType, enums.StickerType]:
152+
def _transform_type(entry: AuditLogEntry, data: int) -> Union[enums.ChannelType, enums.StickerType]:
151153
if entry.action.name.startswith('sticker_'):
152154
return enums.try_enum(enums.StickerType, data)
153155
else:
@@ -210,14 +212,16 @@ class AuditLogChanges:
210212
'privacy_level': (None, _enum_transformer(enums.StagePrivacyLevel)),
211213
'format_type': (None, _enum_transformer(enums.StickerFormatType)),
212214
'type': (None, _transform_type),
215+
'status': (None, _enum_transformer(enums.ScheduledEventStatus)),
216+
'entity_type': ('location_type', _enum_transformer(enums.ScheduledEventLocationType)),
213217
}
214218
# fmt: on
215219

216-
def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]):
220+
def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload], *, state: ConnectionState):
217221
self.before = AuditLogDiff()
218222
self.after = AuditLogDiff()
219223

220-
for elem in data:
224+
for elem in sorted(data, key=lambda i: i['key']):
221225
attr = elem['key']
222226

223227
# special cases for role add/remove
@@ -246,6 +250,14 @@ def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]):
246250
if transformer:
247251
before = transformer(entry, before)
248252

253+
if attr == 'location':
254+
if hasattr(self.before, 'location_type'):
255+
from .scheduled_events import ScheduledEventLocation
256+
if self.before.location_type is enums.ScheduledEventLocationType.external:
257+
before = ScheduledEventLocation(state=state, value=before)
258+
elif hasattr(self.before, 'channel'):
259+
before = ScheduledEventLocation(state=state, value=self.before.channel)
260+
249261
setattr(self.before, attr, before)
250262

251263
try:
@@ -256,6 +268,14 @@ def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]):
256268
if transformer:
257269
after = transformer(entry, after)
258270

271+
if attr == 'location':
272+
if hasattr(self.after, 'location_type'):
273+
from .scheduled_events import ScheduledEventLocation
274+
if self.after.location_type is enums.ScheduledEventLocationType.external:
275+
after = ScheduledEventLocation(state=state, value=after)
276+
elif hasattr(self.after, 'channel'):
277+
after = ScheduledEventLocation(state=state, value=self.after.channel)
278+
259279
setattr(self.after, attr, after)
260280

261281
# add an alias
@@ -463,7 +483,7 @@ def category(self) -> enums.AuditLogActionCategory:
463483
@utils.cached_property
464484
def changes(self) -> AuditLogChanges:
465485
""":class:`AuditLogChanges`: The list of changes this entry has."""
466-
obj = AuditLogChanges(self, self._changes)
486+
obj = AuditLogChanges(self, self._changes, state=self._state)
467487
del self._changes
468488
return obj
469489

@@ -523,3 +543,6 @@ def _convert_target_sticker(self, target_id: int) -> Union[GuildSticker, Object]
523543

524544
def _convert_target_thread(self, target_id: int) -> Union[Thread, Object]:
525545
return self.guild.get_thread(target_id) or Object(id=target_id)
546+
547+
def _convert_target_scheduled_event(self, target_id: int) -> Union[ScheduledEvent, None]:
548+
return self.guild.get_scheduled_event(target_id) or Object(id=target_id)

0 commit comments

Comments
 (0)