diff options
| author | CapnS <[email protected]> | 2019-03-21 12:57:54 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-03-28 17:33:39 -0400 |
| commit | 4ec72135063f0f200f3b7250504eee8bd83c2f02 (patch) | |
| tree | 87d7f0dbf375492d0c0b7f111cb7102cb57b6a91 /discord/user.py | |
| parent | [commands] Fix MinimalHelpCommand opening note signature consistency (diff) | |
| download | discord.py-4ec72135063f0f200f3b7250504eee8bd83c2f02.tar.xz discord.py-4ec72135063f0f200f3b7250504eee8bd83c2f02.zip | |
Added functionality to edit user settings
Changing docs to fit other parts of the lib
Co-Authored-By: CapnS <[email protected]>
Removing Type Checking
Made all of Rapptz's suggested changes
Removing imports that are no longer needed
Diffstat (limited to 'discord/user.py')
| -rw-r--r-- | discord/user.py | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/discord/user.py b/discord/user.py index 134ada61..fcce10a5 100644 --- a/discord/user.py +++ b/discord/user.py @@ -486,6 +486,113 @@ class ClientUser(BaseUser): data = await self._state.http.start_group(self.id, users) 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): """Represents a Discord user. |