Browse Source

Misc. fixes

pull/10109/head
dolfies 4 years ago
parent
commit
225ca0135a
  1. 5
      discord/calls.py
  2. 6
      discord/guild_folder.py
  3. 8
      discord/settings.py
  4. 4
      discord/tracking.py
  5. 22
      discord/user.py

5
discord/calls.py

@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE.
""" """
import datetime import datetime
from typing import List, Optional, TYPE_CHECKING from typing import List, Optional, TYPE_CHECKING, Union
from . import utils from . import utils
from .enums import VoiceRegion, try_enum from .enums import VoiceRegion, try_enum
@ -313,3 +313,6 @@ class GroupCall(PrivateCall):
@_running_only @_running_only
async def stop_ringing(self, *recipients) -> None: async def stop_ringing(self, *recipients) -> None:
await self._state.http.stop_ringing(self._channel_id, *{r.id for r in recipients}) await self._state.http.stop_ringing(self._channel_id, *{r.id for r in recipients})
Call = Union[PrivateCall, GroupCall]

6
discord/guild_folder.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)
@ -24,6 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
from __future__ import annotations
from typing import List, Optional, TYPE_CHECKING from typing import List, Optional, TYPE_CHECKING
from .colour import Colour from .colour import Colour
@ -33,6 +33,8 @@ if TYPE_CHECKING:
from .state import ConnectionState from .state import ConnectionState
from .types.snowflake import Snowflake from .types.snowflake import Snowflake
__all__ = ('GuildFolder',)
class GuildFolder: class GuildFolder:
__slots__ = ('_state', 'id', 'name', '_colour', 'guilds') __slots__ = ('_state', 'id', 'name', '_colour', 'guilds')

8
discord/settings.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
""" """
The MIT License (MIT) The MIT License (MIT)
@ -24,6 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
from __future__ import annotations
from typing import Any, Dict, List, Optional, TYPE_CHECKING from typing import Any, Dict, List, Optional, TYPE_CHECKING
from .enums import FriendFlags, StickerAnimationOptions, Theme, UserContentFilter, try_enum from .enums import FriendFlags, StickerAnimationOptions, Theme, UserContentFilter, try_enum
@ -33,8 +33,10 @@ if TYPE_CHECKING:
from .guild import Guild from .guild import Guild
from .state import ConnectionState from .state import ConnectionState
__all__ = ('UserSettings',)
class Settings: class UserSettings:
"""Represents the Discord client settings. """Represents the Discord client settings.
Attributes Attributes

4
discord/tracking.py

@ -31,9 +31,7 @@ from typing import Any, Dict, Optional
from .types.snowflake import Snowflake from .types.snowflake import Snowflake
__all__ = ( __all__ = ('ContextProperties',)
'ContextProperties',
)
class ContextProperties: # Thank you Discord-S.C.U.M class ContextProperties: # Thank you Discord-S.C.U.M

22
discord/user.py

@ -36,13 +36,13 @@ from .errors import ClientException, NotFound
from .flags import PublicUserFlags from .flags import PublicUserFlags
from .object import Object from .object import Object
from .relationship import Relationship from .relationship import Relationship
from .settings import Settings from .settings import UserSettings
from .utils import _bytes_to_base64_data, cached_slot_property, parse_time, snowflake_time, MISSING from .utils import _bytes_to_base64_data, cached_slot_property, parse_time, snowflake_time, MISSING
if TYPE_CHECKING: if TYPE_CHECKING:
from datetime import datetime from datetime import datetime
from .call import Call from .calls import PrivateCall
from .channel import DMChannel from .channel import DMChannel
from .guild import Guild from .guild import Guild
from .member import VoiceState from .member import VoiceState
@ -664,8 +664,8 @@ class ClientUser(BaseUser):
return [r.user for r in self._state._relationships.values() if r.type is RelationshipType.blocked] return [r.user for r in self._state._relationships.values() if r.type is RelationshipType.blocked]
@property @property
def settings(self) -> Optional[Settings]: def settings(self) -> Optional[UserSettings]:
"""Optional[:class:`Settings`]: Returns the user's settings.""" """Optional[:class:`UserSettings`]: Returns the user's settings."""
return self._state.settings return self._state.settings
async def edit( async def edit(
@ -810,7 +810,7 @@ class ClientUser(BaseUser):
return ClientUser(state=self._state, data=data) return ClientUser(state=self._state, data=data)
async def fetch_settings(self) -> Settings: async def fetch_settings(self) -> UserSettings:
"""|coro| """|coro|
Retrieves your settings. Retrieves your settings.
@ -826,13 +826,13 @@ class ClientUser(BaseUser):
Returns Returns
-------- --------
:class:`Settings` :class:`UserSettings`
The current settings for your account. The current settings for your account.
""" """
data = await self._state.http.get_settings() data = await self._state.http.get_settings()
return Settings(data=data, state=self._state) return UserSettings(data=data, state=self._state)
async def edit_settings(self, **kwargs) -> Settings: # TODO: I really wish I didn't have to do this... async def edit_settings(self, **kwargs) -> UserSettings: # TODO: I really wish I didn't have to do this...
"""|coro| """|coro|
Edits the client user's settings. Edits the client user's settings.
@ -910,7 +910,7 @@ class ClientUser(BaseUser):
Returns Returns
------- -------
:class:`.Settings` :class:`.UserSettings`
The client user's updated settings. The client user's updated settings.
""" """
payload = {} payload = {}
@ -949,7 +949,7 @@ class ClientUser(BaseUser):
state = self._state state = self._state
data = await state.http.edit_settings(**payload) data = await state.http.edit_settings(**payload)
state.settings = settings = Settings(data=data, state=self._state) state.settings = settings = UserSettings(data=data, state=self._state)
return settings return settings
@ -1030,7 +1030,7 @@ class User(BaseUser, discord.abc.Connectable, discord.abc.Messageable):
return self._state._get_private_channel_by_user(self.id) return self._state._get_private_channel_by_user(self.id)
@property @property
def call(self) -> Optional[Call]: def call(self) -> Optional[PrivateCall]:
return getattr(self.dm_channel, 'call', None) return getattr(self.dm_channel, 'call', None)
@property @property

Loading…
Cancel
Save