Skip to content

Commit a5a6ed8

Browse files
committed
feat!: pomelo - add support for new username system
discord/discord-api-docs#6218 Signed-off-by: Mathieu Corsham <McCuber04@outlook.de>
1 parent 35e0e39 commit a5a6ed8

File tree

19 files changed

+911
-490
lines changed

19 files changed

+911
-490
lines changed

discord/activity.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
JOIN_REQUEST: 8,
101101
SYNC: 16,
102102
PLAY: 32
103+
PARTY_PRIVACY_FRIENDS: 64
104+
PARTY_PRIVACY_VOICE_CHANNEL: 128
105+
EMBEDDED: 256
103106
}
104107
"""
105108

discord/channel.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,15 +1314,16 @@ async def edit(
13141314
if slowmode_delay is not MISSING:
13151315
payload['rate_limit_per_user'] = slowmode_delay
13161316

1317-
data = await self._state.http.edit_channel(self.id, options=payload, reason=reason)
1317+
data = await self._state.http.edit_channel(self.id, reason=reason, **payload)
13181318
self._update(self.guild, data)
13191319
return self
13201320

13211321

13221322
class VocalGuildChannel(abc.Connectable, abc.GuildChannel, abc.Messageable):
13231323
__slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit',
13241324
'_state', 'position', '_overwrites', 'category_id',
1325-
'rtc_region', 'slowmode_delay', 'last_message_id',)
1325+
'rtc_region', 'slowmode_delay', 'last_message_id',
1326+
'nsfw', 'video_quality_mode')
13261327

13271328
if TYPE_CHECKING:
13281329
guild: Guild
@@ -2683,7 +2684,7 @@ class ForumPost(ThreadChannel):
26832684
The ID of the post
26842685
"""
26852686
def __init__(self, *, state, guild, data: dict) -> None:
2686-
super().__init__(state=self._state, guild=self.guild, data=data)
2687+
super().__init__(state=state, guild=guild, data=data)
26872688
self._state: ConnectionState = state
26882689
self._applied_tags: utils.SnowflakeList = utils.SnowflakeList(map(int, data.get("applied_tags",[])))
26892690

@@ -2797,7 +2798,7 @@ async def edit(
27972798
if slowmode_delay is not MISSING:
27982799
payload['rate_limit_per_user'] = slowmode_delay
27992800

2800-
data = await self._state.http.edit_channel(self.id, options=payload, reason=reason)
2801+
data = await self._state.http.edit_channel(self.id, reason=reason, **payload)
28012802
return self._update(self.guild, data)
28022803

28032804

discord/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ class DefaultAvatar(Enum):
777777
green = 2
778778
orange = 3
779779
red = 4
780+
pink = 5
780781

781782
def __str__(self):
782783
return self.name

discord/ext/commands/converter.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ class MemberConverter(IDConverter):
122122
1. Lookup by ID.
123123
2. Lookup by mention.
124124
3. Lookup by name#discrim
125-
4. Lookup by name
126-
5. Lookup by nickname
125+
4. Lookup by display name (global_name)
126+
5. Lookup by username
127+
6. Lookup by nickname
127128
128129
.. versionchanged:: 1.5
129130
Raise :exc:`.MemberNotFound` instead of generic :exc:`.BadArgument`
@@ -207,13 +208,14 @@ class UserConverter(IDConverter):
207208
1. Lookup by ID.
208209
2. Lookup by mention.
209210
3. Lookup by name#discrim
210-
4. Lookup by name
211+
4. Lookup by display name (global_name)
212+
5. Lookup by username
211213
212214
.. versionchanged:: 1.5
213215
Raise :exc:`.UserNotFound` instead of generic :exc:`.BadArgument`
214216
215217
.. versionchanged:: 1.6
216-
This converter now lazily fetches users from the HTTP APIs if an ID is passed
218+
This converter now lazily fetches users from the HTTP APIs if an ID is passed,
217219
and it's not available in cache.
218220
"""
219221
async def convert(self, ctx, argument):
@@ -248,7 +250,7 @@ async def convert(self, ctx, argument):
248250
if result is not None:
249251
return result
250252

251-
predicate = lambda u: u.name == arg
253+
predicate = lambda u: u.global_name == arg or u.username == arg
252254
result = discord.utils.find(predicate, state._users.values())
253255

254256
if result is None:

discord/guild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ def get_member_named(self, name: str) -> Optional[Member]:
12301230
return result
12311231

12321232
def pred(m: Member):
1233-
return m.nick == name or m.name == name
1233+
return m.nick == name or m.global_name == name or m.name == name
12341234

12351235
return utils.find(pred, members)
12361236

0 commit comments

Comments
 (0)