Added functionality to edit user settings
Changing docs to fit other parts of the lib Co-Authored-By: CapnS <38225872+CapnS@users.noreply.github.com> Removing Type Checking Made all of Rapptz's suggested changes Removing imports that are no longer needed
This commit is contained in:
parent
43b44751af
commit
4ec7213506
@ -30,7 +30,7 @@ __all__ = ['ChannelType', 'MessageType', 'VoiceRegion', 'SpeakingState',
|
|||||||
'VerificationLevel', 'ContentFilter', 'Status', 'DefaultAvatar',
|
'VerificationLevel', 'ContentFilter', 'Status', 'DefaultAvatar',
|
||||||
'RelationshipType', 'AuditLogAction', 'AuditLogActionCategory',
|
'RelationshipType', 'AuditLogAction', 'AuditLogActionCategory',
|
||||||
'UserFlags', 'ActivityType', 'HypeSquadHouse', 'NotificationLevel',
|
'UserFlags', 'ActivityType', 'HypeSquadHouse', 'NotificationLevel',
|
||||||
'PremiumType']
|
'PremiumType', 'UserContentFilter', 'FriendFlags', 'Theme']
|
||||||
|
|
||||||
class ChannelType(Enum):
|
class ChannelType(Enum):
|
||||||
text = 0
|
text = 0
|
||||||
@ -107,6 +107,22 @@ class ContentFilter(IntEnum):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
class UserContentFilter(IntEnum):
|
||||||
|
disabled = 0
|
||||||
|
friends = 1
|
||||||
|
all_messages = 2
|
||||||
|
|
||||||
|
class FriendFlags(Enum):
|
||||||
|
noone = 0
|
||||||
|
mutual_guilds = 1
|
||||||
|
mutual_friends = 2
|
||||||
|
guild_and_friends = 3
|
||||||
|
everyone = 4
|
||||||
|
|
||||||
|
class Theme(Enum):
|
||||||
|
light = 'light'
|
||||||
|
dark = 'dark'
|
||||||
|
|
||||||
class Status(Enum):
|
class Status(Enum):
|
||||||
online = 'online'
|
online = 'online'
|
||||||
offline = 'offline'
|
offline = 'offline'
|
||||||
|
@ -809,3 +809,6 @@ class HTTPClient:
|
|||||||
|
|
||||||
def leave_hypesquad_house(self):
|
def leave_hypesquad_house(self):
|
||||||
return self.request(Route('DELETE', '/hypesquad/online'))
|
return self.request(Route('DELETE', '/hypesquad/online'))
|
||||||
|
|
||||||
|
def edit_settings(self, **payload):
|
||||||
|
return self.request(Route('PATCH', '/users/@me/settings'), json=payload)
|
||||||
|
107
discord/user.py
107
discord/user.py
@ -486,6 +486,113 @@ class ClientUser(BaseUser):
|
|||||||
data = await self._state.http.start_group(self.id, users)
|
data = await self._state.http.start_group(self.id, users)
|
||||||
return GroupChannel(me=self, data=data, state=self._state)
|
return GroupChannel(me=self, data=data, state=self._state)
|
||||||
|
|
||||||
|
async def edit_settings(self, **kwargs):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Edits the client user's settings. Only applicable to user accounts.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-------
|
||||||
|
afk_timeout: :class:`int`
|
||||||
|
How long (in seconds) the user needs to be AFK until Discord
|
||||||
|
sends push notifications to your mobile device.
|
||||||
|
animate_emojis: :class:`bool`
|
||||||
|
Whether or not to animate emojis in the chat.
|
||||||
|
convert_emoticons: :class:`bool`
|
||||||
|
Whether or not to automatically convert emoticons into emojis.
|
||||||
|
e.g. :-) -> 😃
|
||||||
|
default_guilds_restricted: :class:`bool`
|
||||||
|
Whether or not to automatically disable DMs between you and
|
||||||
|
members of new guilds you join.
|
||||||
|
detect_platform_accounts: :class:`bool`
|
||||||
|
Whether or not to automatically detect accounts from services
|
||||||
|
like Steam and Blizzard when you open the Discord client.
|
||||||
|
developer_mode: :class:`bool`
|
||||||
|
Whether or not to enable developer mode.
|
||||||
|
disable_games_tab: :class:`bool`
|
||||||
|
Whether or not to disable the showing of the Games tab.
|
||||||
|
enable_tts_command: :class:`bool`
|
||||||
|
Whether or not to allow tts messages to be played/sent.
|
||||||
|
explicit_content_filter: :class:`UserContentFilter`
|
||||||
|
The filter for explicit content in all messages.
|
||||||
|
friend_source_flags: :class:`FriendFlags`
|
||||||
|
Who can add you as a friend.
|
||||||
|
gif_auto_play: :class:`bool`
|
||||||
|
Whether or not to automatically play gifs that are in the chat.
|
||||||
|
guild_positions: List[:class:`abc.Snowflake`]
|
||||||
|
A list of guilds in order of the guild/guild icons that are on
|
||||||
|
the left hand side of the UI.
|
||||||
|
inline_attachment_media: :class:`bool`
|
||||||
|
Whether or not to display attachments when they are uploaded in chat.
|
||||||
|
inline_embed_media: :class:`bool`
|
||||||
|
Whether or not to display videos and images from links posted in chat.
|
||||||
|
locale: :class:`str`
|
||||||
|
The RFC 3066 language identifier of the locale to use for the language
|
||||||
|
of the Discord client.
|
||||||
|
message_display_compact: :class:`bool`
|
||||||
|
Whether or not to use the compact Discord display mode.
|
||||||
|
render_embeds: :class:`bool`
|
||||||
|
Whether or not to render embeds that are sent in the chat.
|
||||||
|
render_reactions: :class:`bool`
|
||||||
|
Whether or not to render reactions that are added to messages.
|
||||||
|
restricted_guilds: List[:class:`abc.Snowflake`]
|
||||||
|
A list of guilds that you will not receive DMs from.
|
||||||
|
show_current_game: :class:`bool`
|
||||||
|
Whether or not to display the game that you are currently playing.
|
||||||
|
status: :class:`Status`
|
||||||
|
The clients status that is shown to others.
|
||||||
|
theme: :class:`Theme`
|
||||||
|
The theme of the Discord UI.
|
||||||
|
timezone_offset: :class:`int`
|
||||||
|
The timezone offset to use.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
HTTPException
|
||||||
|
Editing the settings failed.
|
||||||
|
Forbidden
|
||||||
|
The client is a bot user and not a user account.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
:class:`dict`
|
||||||
|
The client user's updated settings.
|
||||||
|
"""
|
||||||
|
payload = {}
|
||||||
|
|
||||||
|
content_filter = kwargs.pop('explicit_content_filter', None)
|
||||||
|
if content_filter:
|
||||||
|
payload.update({'explicit_content_filter': content_filter.value})
|
||||||
|
|
||||||
|
friend_flags = kwargs.pop('friend_source_flags', None)
|
||||||
|
if friend_flags:
|
||||||
|
dicts = [{}, {'mutual_guilds': True}, {'mutual_friends': True},
|
||||||
|
{'mutual_guilds': True, 'mutual_friends': True}, {'all': True}]
|
||||||
|
payload.update({'friend_source_flags': dicts[friend_flags.value]})
|
||||||
|
|
||||||
|
guild_positions = kwargs.pop('guild_positions', None)
|
||||||
|
if guild_positions:
|
||||||
|
guild_positions = [str(x.id) for x in guild_positions]
|
||||||
|
payload.update({'guild_positions': guild_positions})
|
||||||
|
|
||||||
|
restricted_guilds = kwargs.pop('restricted_guilds', None)
|
||||||
|
if restricted_guilds:
|
||||||
|
restricted_guilds = [str(x.id) for x in guild_positions]
|
||||||
|
payload.update({'restricted_guilds': restricted_guilds})
|
||||||
|
|
||||||
|
status = kwargs.pop('status', None)
|
||||||
|
if status:
|
||||||
|
payload.update({'status': status.value})
|
||||||
|
|
||||||
|
theme = kwargs.pop('theme', None)
|
||||||
|
if theme:
|
||||||
|
payload.update({'theme': theme.value})
|
||||||
|
|
||||||
|
payload.update(kwargs)
|
||||||
|
|
||||||
|
data = await self._state.http.edit_settings(**payload)
|
||||||
|
return data
|
||||||
|
|
||||||
class User(BaseUser, discord.abc.Messageable):
|
class User(BaseUser, discord.abc.Messageable):
|
||||||
"""Represents a Discord user.
|
"""Represents a Discord user.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user