Skip to content

Commit

Permalink
Document missing Permissions and User variables;
Browse files Browse the repository at this point in the history
- disco.types.permissions: `USE_CLYDE_AI`, `SET_VOICE_CHANNEL_STATUS`, `SEND_POLLS`;
- disco.types.message: do not create `MessageComponent.emoji` if none;
- disco.types.user: Mapped `15` missing user flags;
- disco.types.user: Mapped `banner_color`, `clan`, `bio`, `avatar_decoration_data` on `User` object;
- disco.voice: misc. optimizations;
  • Loading branch information
elderlabs committed Apr 27, 2024
1 parent 7d4600e commit ec64588
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion disco/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class _MessageComponent(SlottedModel):
disabled = Field(bool)
style = Field(int)
label = Field(text)
emoji = Field(Emoji)
emoji = Field(Emoji, create=False)
url = Field(text)
options = ListField(SelectOption)
placeholder = Field(text)
Expand Down
3 changes: 3 additions & 0 deletions disco/types/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class Permissions(BitsetMap):
CREATE_EVENTS = 1 << 44
USE_EXTERNAL_SOUNDS = 1 << 45
SEND_VOICE_MESSAGES = 1 << 46
USE_CLYDE_AI = 1 << 47
SET_VOICE_CHANNEL_STATUS = 1 << 48
SEND_POLLS = 1 << 49


class PermissionValue(BitsetValue):
Expand Down
33 changes: 31 additions & 2 deletions disco/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UserFlags(BitsetMap):
HYPESQUAD_ONLINE_HOUSE_3 = 1 << 8
PREMIUM_EARLY_SUPPORTER = 1 << 9
TEAM_PSEUDO_USER = 1 << 10
# UNDOCUMENTED = 1 << 11
INTERNAL_APPLICATION = 1 << 11
SYSTEM = 1 << 12
UNREAD_SYS_MSG = 1 << 13
BUG_HUNTER_LEVEL_2 = 1 << 14
Expand All @@ -39,7 +39,21 @@ class UserFlags(BitsetMap):
CERTIFIED_MODERATOR = 1 << 18
BOT_HTTP_INTERACTIONS = 1 << 19
SPAMMER = 1 << 20
DISABLE_PREMIUM = 1 << 21
ACTIVE_DEVELOPER = 1 << 22
HIGH_GLOBAL_RATE_LIMIT = 1 << 33
DELETED = 1 << 34
DISABLED_SUSPICIOUS_ACTIVITY = 1 << 35
SELF_DELETED = 1 << 36
# PREMIUM_DISCRIMINATOR = 1 << 37
USED_DESKTOP_CLIENT = 1 << 38
USED_WEB_CLIENT = 1 << 39
USED_MOBILE_CLIENT = 1 << 40
DISABLED = 1 << 41
VERIFIED_EMAIL = 1 << 43
QUARANTINED = 1 << 44
COLLABORATOR = 1 << 50
RESTRICTED_COLLABORATOR = 1 << 51


class UserFlagsValue(BitsetValue):
Expand All @@ -53,6 +67,18 @@ class PremiumType:
BASIC = 3


class UserAvatarDecorationData(SlottedModel):
asset = Field(text)
sku_id = Field(snowflake)


class UserClan(SlottedModel):
badge = Field(text)
identity_enabled = Field(bool)
identity_guild_id = Field(snowflake)
tags = Field(text)


class User(SlottedModel, with_equality('id'), with_hash('id')):
id = Field(snowflake)
username = Field(text)
Expand All @@ -63,6 +89,7 @@ class User(SlottedModel, with_equality('id'), with_hash('id')):
system = Field(bool, default=False)
mfa_enabled = Field(bool)
banner = Field(text)
banner_color = Field(text)
accent_color = Field(str_or_int)
locale = Field(text)
verified = Field(bool)
Expand All @@ -72,7 +99,9 @@ class User(SlottedModel, with_equality('id'), with_hash('id')):
public_flags = Field(UserFlagsValue)
avatar_decoration = Field(text)
display_name = Field(text)
# avatar_decoration_data = Field(text) ???
clan = Field(UserClan)
bio = Field(text)
avatar_decoration_data = Field(UserAvatarDecorationData)
# member = Field(GuildMember)

def __str__(self):
Expand Down
3 changes: 0 additions & 3 deletions disco/voice/playable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
from gevent.lock import Semaphore as GeventSemaphore
from gevent.subprocess import PIPE as GEVENT_PIPE, Popen as GeventPopen
from io import BytesIO
from struct import calcsize as struct_calcsize
from types import GeneratorType

from disco.util.metaclass import add_metaclass
from disco.voice.opus import OpusEncoder

OPUS_HEADER_SIZE = struct_calcsize('<h')


class AbstractOpus:
def __init__(self, sampling_rate=48000, frame_length=20, channels=2):
Expand Down
4 changes: 1 addition & 3 deletions disco/voice/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ def run(self):
header_size += (rtp.csrc_count * 4)
if rtp.extension:
header_size += 4
ctxt = data[header_size:] # plus strip whatever additional bs is before the payload
else:
ctxt = data[12:]
ctxt = data[header_size:] # plus strip whatever additional bs is before the payload

try:
if self.vc.mode in ('aead_xchacha20_poly1305_rtpsize', 'aead_aes256_gcm', 'aead_aes256_gcm_rtpsize'):
Expand Down

0 comments on commit ec64588

Please sign in to comment.